<jupyter_start><jupyter_text>Complex Graphics with SeabornThroughout this course, we've seen how to use our basic Python skills to create sophisticated data graphics. Some nice developers have created the the Seaborn package, which can automate some of the work for us. Using Seaborn, we can create familiar plots more easily, and create new ones as well. Both base Matplotlib and Seaborn graphics are welcome on your projects. Please keep in mind that you must be ready to explain every facet of a plot. So, if you use a fancy Seaborn function to create a complicated visualization and then discuss only some of its facets, you may lose points for showing unnecessary information.<jupyter_code>import pandas as pd
url = "https://raw.githubusercontent.com/PhilChodrow/PIC16A/master/datasets/gapminder.csv"
gapminder = pd.read_csv(url)
gapminder<jupyter_output><empty_output><jupyter_text>Seaborn builds on the foundation of Matplotlib. It includes several simple commands to make very complex visualizations, including ones which would normally require a `for`-loop or use of `apply`.  The cost of all this power is that it is sometimes more difficult to exercise fine-grained control over the details. One of the main differences between Seaborn and Matplotlib is that Seaborn accepts the names of dataframe columns for many arguments.<jupyter_code>import seaborn as sns
sns.relplot("gdpPercap", "lifeExp", data = gapminder)
sns.relplot("gdpPercap", "lifeExp",
            hue = "continent", # make the color vary by continent
            data = gapminder)
# fancier
sns.relplot("gdpPercap", "lifeExp",
            hue = "continent", # make the color vary by continent
            col = "continent",
            col_wrap = 3,
            data = gapminder)
# fancier
sns.relplot("gdpPercap", "lifeExp", 
           hue = "continent",
           size = "pop", 
           data = gapminder[gapminder["year"] == 2007],
           sizes = (20, 700),
           alpha = 0.7)
# fancier<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07117969138875062, 'fraction_numerical': 0.006968641114982578, 'mean_word_length': 3.831730769230769, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, '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': '604174', 'license': 'MIT', 'n_tokens_mistral': 585, 'n_tokens_neox': 556, 'n_words': 238, 'path': 'live_lectures/seaborn.ipynb', 'repo_name': 'mm5110/PIC16A', 'size': '2009'}