Aadi helps!!
Changing color
Change the default figure size
plt.figure(figsize=(10,10))
plt.scatter(x,y, c='green', marker='*')
plt.xticks(np.arange(0, 731, 60))
plt.xticks (rotation=30)
Add x and y labels, title and set a font size
plt.xlabel ("Date", fontsize = 24)
plt.ylabel ("Mean Temperature", fontsize = 24)
plt.title('Mean Temperature at Jaipur', fontsize = 30)
Set the font size of the number labels on the axes
plt.xticks (fontsize = 12)
plt.yticks (fontsize = 12)
plt.xticks (rotation=30, horizontalalignment='right')
plt.show()
Saving plot
plt.savefig("jaipur_scatter_plot.png")
Line Plots
y = dataframe.mean_temperature
plt.plot(y)
plt.ylabel("Mean Temperature")
plt.xlabel("Time")
Y_tick = ['May16','Jul16','Sept16','Nov16','Jan17','Mar17','May17','Jul17','Sept17','Nov17','Jan18','Mar18' ]
plt.xticks(np.arange(0, 731, 60), Y_tick , rotation=30)
plt.xticks()
plt.show()
Drawing multiple lines in a plot
x = dataframe.date
y_1 = dataframe.max_temperature
y_2 = dataframe.min_temperature
plt.plot(x,y_1, label = "Max temp")
plt.plot(x,y_2, label = "Min temp")
plt.xticks(np.arange(0, 731, 60))
plt.xticks (rotation=30)
plt.legend()
plt.show()
Draw at least 3 line graphs in one plot!
Change the default figure size
plt.figure(figsize=(20,10))
x = dataframe.date
y_1 = dataframe.max_temperature
y_2 = dataframe.min_temperature
y_3 = dataframe.mean_temperature
z = y_1-y_2
plt.plot(x,y_1, label = "Max temp")
plt.plot(x,y_2, label = "Min temp")
plt.plot(x,y_3, label = "Mean temp")
plt.plot(x,z, label = "range")
plt.xticks(np.arange(0, 731, 60))
plt.xticks (rotation=30)
plt.legend()
plt.show()
Bar Charts
import matplotlib.pyplot as plt
import numpy as np
x_pos = ['Python', 'C++', 'Java', 'Perl', 'Scala', 'Lisp']
usage = [10,8,6,4,2,1]
plt.bar(x_pos, usage, align='center')
plt.show()
Task 12: Change your marker shape!
Change the default figure size
plt.figure(figsize=(10,10))
plt.scatter(x,y, marker='*')
plt.xticks(np.arange(0, 731, 60))
plt.xticks (rotation=30)
Add x and y labels, title and set a font size
plt.xlabel ("Date", fontsize = 24)
plt.ylabel ("Mean Temperature", fontsize = 24)
plt.title('Mean Temperature at Jaipur', fontsize = 30)
Set the font size of the number labels on the axes
plt.xticks (fontsize = 12)
plt.yticks (fontsize = 12)
plt.xticks (rotation=30, horizontalalignment='right')
plt.show()
Giving label to the x and y axis
plt.scatter(x,y)
plt.xticks(np.arange(0, 731, 60))
plt.xticks (rotation=30)
Add x and y labels and set a font size
plt.xlabel ("Date", fontsize = 14)
plt.ylabel ("Mean Temperature", fontsize = 14)
plt.show()
Task 10: Now, let's add a title.
plt.scatter(x,y)
plt.xticks(np.arange(0, 731, 60))
plt.xticks (rotation=30)
Add x and y labels and set a font size
plt.xlabel ("Date", fontsize = 14)
plt.ylabel ("Mean Temperature", fontsize = 14)
plt.title('Mean Temperature at Jaipur')
plt.show()
Task 6: Sort the values in ascending order of mean temperature and print the first 5 rows
jaipur_weather = dataframe.sort_values(by='mean_temperature',ascending = True)
print(jaipur_weather.head(5))