In [1]:
import pandas as pd
import matplotlib.pyplot as plt
df3 = pd.read_csv('df3')
%matplotlib inline
In [2]:
df3.info()
In [3]:
df3.head()
Out[3]:
Recreate this scatter plot of b vs a. Note the color and size of the points. Also note the figure size. See if you can figure out how to stretch it in a similar fashion. Remeber back to your matplotlib lecture...
In [4]:
df3.plot.scatter(x='a',y='b',c='red',s=50,figsize=(12,3))
Out[4]:
Create a histogram of the 'a' column.
In [5]:
df3['a'].plot.hist()
Out[5]:
These plots are okay, but they don't look very polished. Use style sheets to set the style to 'ggplot' and redo the histogram from above. Also figure out how to add more bins to it.*
In [6]:
plt.style.use('ggplot')
In [7]:
df3['a'].plot.hist(alpha=0.5,bins=25)
Out[7]:
Create a boxplot comparing the a and b columns.
In [8]:
df3[['a','b']].plot.box()
Out[8]:
Create a kde plot of the 'd' column
In [9]:
df3['d'].plot.kde()
Out[9]:
Figure out how to increase the linewidth and make the linestyle dashed. (Note: You would usually not dash a kde plot line)
In [10]:
df3['d'].plot.density(lw=5,ls='--')
Out[10]:
Create an area plot of all the columns for just the rows up to 30. (hint: use .ix).
In [15]:
df3.ix[0:30].plot.area(alpha=0.4)
Out[15]:
Note, you may find this really hard, reference the solutions if you can't figure it out! Notice how the legend in our previous figure overlapped some of actual diagram. Can you figure out how to display the legend outside of the plot as shown below?
Try searching Google for a good stackoverflow link on this topic. If you can't find it on your own - use this one for a hint.
In [17]:
f = plt.figure()
df3.ix[0:30].plot.area(alpha=0.4,ax=f.gca())
plt.legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
plt.show()