<jupyter_start><jupyter_text>Seaborn Contents1&nbsp;&nbsp;Introduction2&nbsp;&nbsp;Data3&nbsp;&nbsp;Plotting  IntroductionThis uses Matplotlib in the background, but the API is designed mainly for statistics and visualization of complex data. Exploring datasets is intended to be quick and simple using very terse commands compared with other plotting packages.The `set()` function changes many of Matplotlib's defaults for the entire notebook.<jupyter_code>import numpy as np
import pandas as pd
import seaborn as sns
sns.set()<jupyter_output><empty_output><jupyter_text>DataSeaborn documentation uses several standard datasets. This command lists their names, along with verbose warning messages:<jupyter_code># sns.get_dataset_names()<jupyter_output><empty_output><jupyter_text>We will use the galaxies data, in a pandas dataframe with some calculated fields added. There is no need to split by specClass, Seaborn will do that on the fly. In fact, Seaborn's strength is anticipating your needs with a rich set of options and sensible defaults - kudos to the designers!<jupyter_code>data = pd.read_pickle('sdss_colors.pkl')
data[:3]<jupyter_output><empty_output><jupyter_text>PlottingA quick and basic plot:<jupyter_code>sns.relplot(x='u-g', y="g-r", 
            col="specClass", style="specClass", 
            size="redshift", 
            data=data);<jupyter_output><empty_output><jupyter_text>Add a regression line with 95% confidence intervals. This is just a linear fit, but `lmplot()` also works with higher order polynomials, logistic regression and a variety of specialized fits.<jupyter_code>sns.lmplot(x='u-g', y="g-r", col="specClass", data=data);<jupyter_output>/home/colin/anaconda3/envs/ml/lib/python3.6/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval<jupyter_text>Plot everything against everything, to get a quick feel for relations. Seaborn will choose an appropriate plot type in each case - only scatter and line plots here; categorical fields can appear as histograms.Perhaps cutting down the number of columns would be sensible!<jupyter_code>df = data.drop('redshift_err', axis=1)

sns.pairplot(data=df, hue="specClass");
sns.boxplot(x="far", y="u-g",
            hue="specClass", 
            data=data);<jupyter_output><empty_output><jupyter_text>For large numbers of data points, a jointplot will show a bivariate distribution with both univariate distributions. First exapmle as hexagon plot:<jupyter_code>with sns.axes_style("white"):
    sns.jointplot(x='u-g', y="g-r", data=data, kind="hex", color="k");<jupyter_output><empty_output><jupyter_text>Same data as kernel density estimation ("kde"):<jupyter_code>sns.jointplot(x='u-g', y="g-r", data=data, kind="kde");
sns.jointplot(x='u-g', y="g-r", data=data, kind="reg");<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10750962772785623, 'fraction_numerical': 0.004492939666238768, 'mean_word_length': 6.100227790432802, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '132997', 'license': 'MIT', 'n_tokens_mistral': 993, 'n_tokens_neox': 953, 'n_words': 303, 'path': 'dataviz/plotting/Seaborn.ipynb', 'repo_name': 'colinleach/tinkerings', 'size': '3116'}