<jupyter_start><jupyter_text>Plots Categóricos- factorplot- boxplot- violinplot- stripplot- swarmplot- barplot- countplot<jupyter_code>import seaborn as sns
import numpy as np
sns.set(style='darkgrid') # altera os estilo dos plot
%matplotlib inline
tips = sns.load_dataset('tips')
tips.head()
tips.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 244 entries, 0 to 243
Data columns (total 7 columns):
total_bill    244 non-null float64
tip           244 non-null float64
sex           244 non-null category
smoker        244 non-null category
day           244 non-null category
time          244 non-null category
size          244 non-null int64
dtypes: category(4), float64(2), int64(1)
memory usage: 7.2 KB<jupyter_text>sns.barplotx define a categoria e y dados a serem calculados após agruado em função de cada categoria em x<jupyter_code>sns.barplot(x='sex', y='total_bill', data=tips)
sns.barplot(x='sex', y='total_bill', data=tips, estimator=np.std)<jupyter_output><empty_output><jupyter_text>sns.countplotRetorna um gráfico com a contagem de quanto dados existem para cada categoria que há no conjunto informado como *x*<jupyter_code>sns.countplot(x='sex', data=tips)<jupyter_output><empty_output><jupyter_text>sns.boxplot<jupyter_code>sns.boxplot(x='day', y='total_bill', data=tips)<jupyter_output><empty_output><jupyter_text>O parâmetro `hue` subdivide as categorias segundo o valor passado:<jupyter_code>sns.boxplot(x='day', y='total_bill', data=tips, hue='sex')<jupyter_output><empty_output><jupyter_text>Exemplo de paleta de cores `rainbow`:<jupyter_code>sns.boxplot(x='day', y='total_bill', data=tips, palette='rainbow')<jupyter_output><empty_output><jupyter_text>O atributo `orient` define a orientação de exibição do gráfico:<jupyter_code>sns.boxplot(x='total_bill', data=tips, orient='h')<jupyter_output><empty_output><jupyter_text>sns.violinplot Exibe a distribuição dos dados, em `y`, usando KDE baseado na categoria passada para `x`.<jupyter_code>sns.violinplot(x='day', y='tip', data=tips)<jupyter_output><empty_output><jupyter_text>Assim com o já apresentado, `hue` subdivide o gráfico baseado sem seu parâmetro.<jupyter_code>sns.violinplot(x='day', y='tip', data=tips, hue='sex', split=True)<jupyter_output><empty_output><jupyter_text>sns.stripplot<jupyter_code>sns.stripplot(x='day', y='total_bill', data=tips, jitter=True, hue='sex', dodge=True)<jupyter_output><empty_output><jupyter_text>sns.swarmplot<jupyter_code>sns.swarmplot(x='day', y='total_bill', data=tips, hue='sex', dodge=True)<jupyter_output><empty_output><jupyter_text>combinando dois plots<jupyter_code>sns.swarmplot(x='day', y='total_bill', data=tips, color='black')
sns.violinplot(x='day', y='total_bill', data=tips)<jupyter_output><empty_output><jupyter_text>sns.factorplotA função `factorplot` é capaz de criar outros plot através do que é definido no parâmetro `kind`<jupyter_code>sns.factorplot(x='sex', y='total_bill', data=tips, kind='bar')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1327315279170846, 'fraction_numerical': 0.014710799063858242, 'mean_word_length': 8.121951219512194, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '342723', 'license': 'MIT', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1149, 'n_words': 222, 'path': 'anotacoes/seaborn/seaborn-categorical_plots.ipynb', 'repo_name': 'jonatasleon/data-science-py', 'size': '2991'}