basic matplotlib functions code example
Example 1: matplotlib line plot
from matplotlib import pyplot as plt
dev_x = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
dev_y = [38496, 42000, 46752, 49320, 53200,
56000, 62316, 64928, 67317, 68748, 73752]
plt.plot(dev_x, dev_y)
plt.xlabel('Ages')
plt.ylabel('Median Salary (USD)')
plt.title('Median Salary (USD) by Age')
plt.show()
Example 2: show graph matplotlib axes
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("filesc/file1.csv")
df.head()
BBox = ((df.x.min(), df.x.max(), df.y.min(), df.y.max()))
ruh_m = plt.imread('map.png')
print(BBox)
fig, ax = plt.subplots(figsize = (8,7))
ax.scatter(df.x, df.y, zorder=1, alpha= 0.2, c='b', s=10)
ax.set_title('Plotting Spatial Data on Map')
ax.set_xlim(BBox[0],BBox[1])
ax.set_ylim(BBox[2],BBox[3])
ax.imshow(ruh_m, zorder=0, extent = BBox, aspect= 'equal')
plt.show()