<jupyter_start><jupyter_text>Lesson 7 Practice: MatplotlibUse this notebook to follow along with the lesson in the corresponding lesson notebook: [L07-Matplotlib-Lesson.ipynb](./L07-Matplotlib-Lesson.ipynb).    InstructionsFollow along with the teaching material in the lesson. Throughout the tutorial sections labeled as "Tasks" are interspersed and indicated with the icon: ![Task](http://icons.iconarchive.com/icons/sbstnblnd/plateau/16/Apps-gnome-info-icon.png). You should follow the instructions provided in these sections by performing them in the practice notebook.  When the tutorial is completed you can turn in the final practice notebook. For each task, use the cell below it to write and test your code.  You may add additional cells for any task as needed or desired.    Task 1a: SetupImport the following packages:+ `pandas` as `pd`+ `numpy` as `np`+ `matplotlib.pyplot` as `plt`Activate the `%matplotlib inline` magic.<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Task 1b: Load DataLoad the Iris data (same as in the Pandas tasks).<jupyter_code>iris_df = pd.read_csv('./data/iris.csv')
iris_df.head()<jupyter_output><empty_output><jupyter_text>Task 2a: Create a figureCreate the a scatter plot using the iris data, but compare `petal_width` to `petal_length`.  Be sure to add labels to the axes.<jupyter_code># creating figure and axes
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.scatter(iris_df['petal_length'],iris_df['petal_width'])

# adding axis labels
ax.axes.set_xlabel('petal length')
ax.axes.set_ylabel('petal width')

# adding Plot Title
ax.set_title("Petal Length vs Width")

plt.show()<jupyter_output><empty_output><jupyter_text>Task 3a: Figure StyleCreate a scatter plots using the iris data frame. Do not convert the data frame columns to numpy arrays. Rather use the dataframe as is. Be sure to:- plot `petal_length` vs `petal_width`.- Use column names to specify the x and y coordinates (don't pass in Numpy arrays)- Color each dot by the species (you'll need to be creative to do this).  - Hint 1: use the [pd.Series.replace](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.replace.html) function to convert species names to colors).   - Hint 2: Use the color abbreviations we learned for the the plot function (e.g. 'r', 'b', 'g', etc.).- Add axis labels<jupyter_code>iris_df['species'].unique()
# adding a column to specify different color for each species

species_color = iris_df['species']
species_color = species_color.replace(['setosa','versicolor','virginica'],['r','g','b'])
iris_df['species_color'] = species_color
iris_df.sample(5)

# creating figure and axes
fig = plt.figure()
ax = fig.add_subplot(1,1,1)

#ax.scatter(iris_df['petal_length'],iris_df['petal_width'],c= iris_df['species_color'])
ax.scatter('petal_length','petal_width', c = 'species_color',data = iris_df)


# adding axis labels
ax.axes.set_xlabel('petal length')
ax.axes.set_ylabel('petal width')

# adding Plot Title
ax.set_title("Petal Length vs Width")


plt.show()<jupyter_output><empty_output><jupyter_text>Task 4a: Categorical plotsCreate a bar graph that indicates the mean `sepal_length` of each subspecies.<jupyter_code># creating figure and axes
fig = plt.figure()
ax = fig.add_subplot(1,1,1)

sepal_length_mean = iris_df.groupby(by='species')['sepal_length'].mean()

ax.bar(sepal_length_mean.index,sepal_length_mean.values)
ax.set_title("Mean sepal length for each species")

plt.show()<jupyter_output><empty_output><jupyter_text>Task 6a:  Multiple PlotsCreate 4 scatterplots for the iris data all in one figure. The figure should include scatterplots of these comparisions:- `sepal_length` x `petal_length`- `sepal_length` x `petal_width`- `sepal_width` x `petal_length`- `sepal_width` x `petal_width`Be sure that:- the points for the species - the axes for each plot are labeled- the figure has a label.<jupyter_code>fig,axes = plt.subplots(2,2 ,figsize=(10,10))
axes[0,0].scatter('sepal_length','petal_length',c='species_color',data=iris_df)
axes[0,0].set_xlabel('Sepal Length')
axes[0,0].set_ylabel('Petal Length')

axes[0,1].scatter('sepal_length','petal_width',c='species_color',data=iris_df)
axes[0,1].set_xlabel('Sepal Length')
axes[0,1].set_ylabel('Petal Width')
                     
axes[1,0].scatter('sepal_width','petal_length',c='species_color',data=iris_df)
axes[1,0].set_xlabel('Sepal Width')
axes[1,0].set_ylabel('Petal Length')

axes[1,1].scatter('sepal_width','petal_width',c='species_color',data=iris_df)
axes[0,0].set_xlabel('Sepal Width')
axes[0,0].set_ylabel('Petal Width')

fig.suptitle("Comparison between sepal and petal dimensions")

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12279226240538267, 'fraction_numerical': 0.011774600504625737, 'mean_word_length': 6.318461538461539, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '317546', 'license': 'Apache-2.0', 'n_tokens_mistral': 1690, 'n_tokens_neox': 1614, 'n_words': 447, 'path': 'L07-Matplotlib-Practice.ipynb', 'repo_name': 'saioruganti/Data-Analytics-With-Python', 'size': '4756'}