Thursday, June 10, 2021

【PYTHON】Plotting with DataFrames

 import matplotlib.pyplot as plt


itunes_df['Milliseconds'].hist(bins=30)

plt.show()


# this cell is for saving the image; more on this is chapter 5

f = plt.figure(figsize=(5.5, 5.5))  # this changes the size of the image -- more on this is chapter 5

f.patch.set_facecolor('w')  # sets background color behind axis labels

itunes_df['Milliseconds'].hist(bins=30)

plt.tight_layout()  # auto-adjust margins

plt.savefig('B17030_04_06.png', dpi=300)


# figsize increases the size of the image -- more on this is chapter 5

itunes_df.plot.scatter(x='Milliseconds', y='Bytes', figsize=(8, 8))

plt.show()


# saving the image -- more on this in chapter 5

f = plt.figure()

itunes_df.plot.scatter(x='Milliseconds', y='Bytes', figsize=(5.5, 5.5))

f.patch.set_facecolor('w')  # sets background color behind axis labels

plt.tight_layout()  # auto-adjust margins

plt.savefig('B17030_04_07.png', dpi=300)


itunes_df.iloc[-1, -1]


itunes_df.loc[3502]

No comments:

Post a Comment