import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
# Omitir warnings
import warnings
warnings.filterwarnings('ignore')
# tamaño de figura
fig = plt.figure(figsize=(12, 8))
# Lectura de csv
df = pd.read_csv('https://vincentarelbundock.github.io/Rdatasets/csv/datasets/mtcars.csv')
# Grafico
ax = sns.regplot(x="wt", y="mpg", data=df)
ax.set(xlabel='MPG', ylabel='WT')
plt.title('Peso vs mpg')
Text(0.5, 1.0, 'Peso vs mpg')
import pandas as pd
import seaborn as sns
df = pd.read_csv('https://raw.githubusercontent.com/marsja/jupyter/master/flanks.csv',
index_col=0)
# Grafico
fig = plt.figure(figsize=(12, 8))
for condition in df.TrialType.unique():
cond_data = df[(df.TrialType == condition)]
ax = sns.distplot(cond_data.RT, kde=False, label=condition)
ax.set(xlabel='Tiempo de respuesta', ylabel='Frecuencia')
ax.legend()
ax.set_title('Histogramas Tiempo de respuesta')
Text(0.5, 1.0, 'Histogramas Tiempo de respuesta')
import pandas as pd
import seaborn as sns
# Leer el archivo
df = pd.read_csv('https://vincentarelbundock.github.io/Rdatasets/csv/datasets/mtcars.csv', index_col=0)
# Hacer la agrupacion
df_grpd = df.groupby("cyl").count().reset_index()
# Grafico
fig = plt.figure(figsize=(12, 8))
sns.barplot(x="cyl", y="mpg", data=df_grpd)
ax.set(xlabel='Cylinders', ylabel='Number of Cars for Each Cylinder')
[Text(17.200000000000003, 0.5, 'Number of Cars for Each Cylinder'), Text(0.5, 17.200000000000003, 'Cylinders')]
import pandas as pd
import seaborn as sns
df = pd.read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-02-26/full_trains.csv")
plt.figure(figsize=(12, 8))
sns.lineplot(x="month", y="total_num_trips", hue="departure_station",
ci=None, data=df[df.departure_station.str.contains('PARIS')])
plt.xlabel('Mes')
plt.ylabel('Numer de viajes')
plt.title('Viajes por mes')
Text(0.5, 1.0, 'Viajes por mes')
import pandas as pd
import seaborn as sns
df = pd.read_csv('https://vincentarelbundock.github.io/Rdatasets/csv/datasets/mtcars.csv', index_col=0)
fig = plt.figure(figsize=(12, 8))
sns.boxplot(x="vs", y='wt', data=df)
plt.title('Vs vs WT')
Text(0.5, 1.0, 'Vs vs WT')
!pip install ptitprince
Collecting ptitprince Downloading ptitprince-0.2.5.tar.gz (9.2 kB) Requirement already satisfied: seaborn>=0.10 in /usr/local/lib/python3.7/dist-packages (from ptitprince) (0.11.2) Requirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from ptitprince) (3.2.2) Requirement already satisfied: numpy>=1.13 in /usr/local/lib/python3.7/dist-packages (from ptitprince) (1.21.5) Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from ptitprince) (1.4.1) Collecting PyHamcrest>=1.9.0 Downloading PyHamcrest-2.0.3-py3-none-any.whl (51 kB) |████████████████████████████████| 51 kB 459 kB/s Requirement already satisfied: cython in /usr/local/lib/python3.7/dist-packages (from ptitprince) (0.29.28) Requirement already satisfied: pandas>=0.23 in /usr/local/lib/python3.7/dist-packages (from seaborn>=0.10->ptitprince) (1.3.5) Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->ptitprince) (0.11.0) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->ptitprince) (3.0.7) Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->ptitprince) (2.8.2) Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->ptitprince) (1.3.2) Requirement already satisfied: pytz>=2017.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=0.23->seaborn>=0.10->ptitprince) (2018.9) Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.1->matplotlib->ptitprince) (1.15.0) Building wheels for collected packages: ptitprince Building wheel for ptitprince (setup.py) ... done Created wheel for ptitprince: filename=ptitprince-0.2.5-py3-none-any.whl size=8426 sha256=a5be4611e2596b33121e90b49be17a33416c7664bbefdb47badc956f2687d23f Stored in directory: /root/.cache/pip/wheels/58/a5/f2/55920bbc5d0e6fb74b2370e1e52e07c236ba7b621236ea5a81 Successfully built ptitprince Installing collected packages: PyHamcrest, ptitprince Successfully installed PyHamcrest-2.0.3 ptitprince-0.2.5
import pandas as pd
import ptitprince as pt
df = pd.read_csv('https://vincentarelbundock.github.io/Rdatasets/csv/datasets/iris.csv')
ax = pt.RainCloud(x = 'Species', y = 'Sepal.Length',
data = df,
width_viol = .8,
width_box = .4,
orient = 'h',
move = .0)