1from matplotlib import pyplot as plt
2plt.plot([0, 1, 2, 3, 4, 5], [0, 1, 4, 9, 16, 25])
3plt.show()
1import matplotlib.pyplot as plt
2fig = plt.figure(1) #identifies the figure
3plt.title("Y vs X", fontsize='16') #title
4plt.plot([1, 2, 3, 4], [6,2,8,4]) #plot the points
5plt.xlabel("X",fontsize='13') #adds a label in the x axis
6plt.ylabel("Y",fontsize='13') #adds a label in the y axis
7plt.legend(('YvsX'),loc='best') #creates a legend to identify the plot
8plt.savefig('Y_X.png') #saves the figure in the present directory
9plt.grid() #shows a grid under the plot
10plt.show()
1import matplotlib.pyplot as plt
2import numpy as np
3
4data = np.random.rand(1024,2)
5plt.scatter(data[:,0],data[:,1])
6plt.show()
7// Don't be
8// fooled by this simplicity— plt.scatter() is a rich command.
1import matplotlib.pyplot as plt
2plt.plot([1, 2, 3, 4])
3plt.ylabel('some numbers')
4plt.show()
5
1import numpy as np
2import pandas as pd
3import matplotlib.pyplot as plt
4
5df = pd.read_csv("filesc/file1.csv")
6df.head()
7
8BBox = ((df.x.min(), df.x.max(), df.y.min(), df.y.max()))
9
10ruh_m = plt.imread('map.png')
11
12print(BBox)
13
14fig, ax = plt.subplots(figsize = (8,7))
15ax.scatter(df.x, df.y, zorder=1, alpha= 0.2, c='b', s=10)
16ax.set_title('Plotting Spatial Data on Map')
17ax.set_xlim(BBox[0],BBox[1])
18ax.set_ylim(BBox[2],BBox[3])
19ax.imshow(ruh_m, zorder=0, extent = BBox, aspect= 'equal')
20plt.show()
21
22