Python Notes Set 7
Python Notes Set 7
Line Plot:
plt.title("Line Plot")
plt.xlabel("X")
plt.ylabel("Y")
plt.show()
Page 2: Bar, Scatter, Histogram
Bar Plot:
Scatter Plot:
Histogram:
plt.hist([1, 2, 1, 3, 4])
Tips dataset:
tips = sns.load_dataset("tips")
Correlation Heatmap:
sns.heatmap(tips.corr(), annot=True)
Page 4: Plot Styling
Line styles:
Legends:
plt.legend(["Label1", "Label2"])
Subplots:
plt.subplot(1, 2, 1)
plt.plot(x, y)
Page 5: Saving and Exporting Figures
Save figure:
plt.savefig("plot.png")
plt.savefig("plot.pdf", dpi=300)