<jupyter_start><jupyter_text>Activity 4: Complete Plot Design<jupyter_code>%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns

url = "https://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data"
df = pd.read_csv(url)

column_names = ['mpg', 'cylinders', 'displacement', 'horsepower', 'weight', 'acceleration', 'year', 'origin', 'name']
df = pd.read_csv(url, names= column_names, delim_whitespace=True)
df_g = df.groupby(['year', 'cylinders'], as_index=False)
df_g = df_g.mpg.mean()
df_g
df_g = df_g.set_index(df_g.year)
df_g
import matplotlib.pyplot as plt
fig, axes = plt.subplots()

df = df.convert_objects(convert_numeric=True)
df_g = df.groupby(['year', 'cylinders'], as_index=False).horsepower.mean()
df_g = df_g.set_index(df_g.year)
fig, axes = plt.subplots()
df_g.groupby('cylinders').horsepower.plot(axes=axes, figsize=(12,10))
_ = axes.set(
    title="Average car power per year",
    xlabel="Year",
    ylabel="Power (horsepower)"    
)
axes.legend(title='Cylinders', fancybox=True)
fig.savefig('mpg_cylinder_year.png')
fig.savefig('mpg_cylinder_year.png')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15378221113881962, 'fraction_numerical': 0.004156275976724855, 'mean_word_length': 6.432098765432099, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '11750', 'license': 'MIT', 'n_tokens_mistral': 492, 'n_tokens_neox': 471, 'n_words': 88, 'path': 'Lesson02/Activity04.ipynb', 'repo_name': 'bsitati/Big-Data-Analysis-with-Python', 'size': '1203'}