Issue
I am trying to create a 2x2 plots for Anscombe data-set
Loading Data-set and separating each class in data-set
import seaborn as sns
import matplotlib.pyplot as plt
anscombe = sns.load_dataset('anscombe')
dataset_1 = anscombe[anscombe['dataset'] == 'I']
dataset_2 = anscombe[anscombe['dataset'] == 'II']
dataset_3 = anscombe[anscombe['dataset'] == 'III']
dataset_4 = anscombe[anscombe['dataset'] == 'IV']
Creating a figure and dividing into 4 parts
fig = plt.figure()
axes_1 = fig.add_subplot(2,2,1)
axes_2 = fig.add_subplot(2,2,2)
axes_3 = fig.add_subplot(2,2,3)
axes_4 = fig.add_subplot(2,2,4)
axes_1.plot(dataset_1['x'], dataset_1['y'], 'o')
axes_2.plot(dataset_2['x'], dataset_2['y'], 'o')
axes_3.plot(dataset_3['x'], dataset_3['y'], 'o')
axes_4.plot(dataset_4['x'], dataset_4['y'], 'o')
axes_1.set_title('dataset_1')
axes_2.set_title('dataset_2')
axes_3.set_title('dataset_3')
axes_4.set_title('dataset_4')
fig.suptitle('Anscombe Data')
fig.tight_layout()
The only output which i'm getting at each plot is
[<matplotlib.lines.Line2D at 0x24592c94bc8>]
What am I doing wrong?
Solution
If you are working with a Jupyter Notebook then you can add the following line to the top cell where you call all your imports. The following command will render your graph
%matplotlib inline
Answered By - Rohan Nagavardhan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.