<jupyter_start><jupyter_text>Other plotting librariesWe've already seen Matplotlib and Altair.  The point of this notebook is to show a few other popular libraries, which will have syntax very similar to Altair.<jupyter_code>import pandas as pd
import numpy as np
import seaborn as sns
import plotly.express as px
import holoviews as hv
import altair as alt
from matplotlib import pyplot as plt
from sklearn.datasets import load_iris
sns.get_dataset_names()
diamonds = sns.load_dataset('diamonds')
diamonds.columns
sns.scatterplot(data=diamonds,x='carat',y='price',hue='cut')
titanic = sns.load_dataset("titanic")
alt.Chart(titanic.query("20<fare<100")).mark_point().encode(
    x = 'age',
    y = 'fare',
    color = 'survived:N',
)
planets = sns.load_dataset("planets")
planets.isnull().any(axis=1).sum()
alt.Chart(planets.query('orbital_period<300')).mark_circle().encode(
    x = 'distance',
    y = 'orbital_period',
)<jupyter_output><empty_output><jupyter_text>I think this is too much of a digression.  Let's get a dataset from Seaborn instead.<jupyter_code>iris = load_iris()
iris.feature_names
cols = ['_'.join(x.split()[:2]) for x in iris.feature_names]
# An easier way which is only somewhat less robust.
[x[:-5].replace(" ","_") for x in iris.feature_names]
# Who knows what this is
type(iris)
df_iris = pd.DataFrame(iris.data,columns=cols)
# We can't initialize a new column using the attribute notation df_iris.class
# Actually I guess we can never use .class, maybe that is a restricted term.
df_iris["class"] = np.nan
df_iris
# We could have also just done this at the beginning.
df_iris["class"] = iris.target
df_iris
iris.target_names
df_iris["class"].map(lambda x: iris.target_names[x])
#Notice we haven't changed anything yet
df_iris
df_iris["class"] = df_iris["class"].map(lambda x: iris.target_names[x])
df_iris
df_iris["class"].value_counts()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12189973614775726, 'fraction_numerical': 0.005804749340369393, 'mean_word_length': 5.869565217391305, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '571628', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 679, 'n_tokens_neox': 666, 'n_words': 188, 'path': 'Drafts/Other plotting libraries.ipynb', 'repo_name': 'ChristopherDavisUCI/UCI-Math-10-Davis', 'size': '1895'}