1from matplotlib import pyplot as plt
2plt.plot([0, 1, 2, 3, 4, 5], [0, 1, 4, 9, 16, 25])
3plt.show()
1from matplotlib import pyplot as plt
2
3# Median Developer Salaries by Age
4dev_x = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
5
6dev_y = [38496, 42000, 46752, 49320, 53200,
7 56000, 62316, 64928, 67317, 68748, 73752]
8
9plt.plot(dev_x, dev_y)
10plt.xlabel('Ages')
11plt.ylabel('Median Salary (USD)')
12plt.title('Median Salary (USD) by Age')
13plt.show()
14
15#Basic line graph using python module matplotlib
1import matplotlib.pyplot as plt
2from matplotlib import cm
3from matplotlib.ticker import LinearLocator
4import numpy as np
5
6fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
7
8# Make data.
9X = np.arange(-5, 5, 0.25)
10Y = np.arange(-5, 5, 0.25)
11X, Y = np.meshgrid(X, Y)
12R = np.sqrt(X**2 + Y**2)
13Z = np.sin(R)
14
15# Plot the surface.
16surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
17 linewidth=0, antialiased=False)
18
19# Customize the z axis.
20ax.set_zlim(-1.01, 1.01)
21ax.zaxis.set_major_locator(LinearLocator(10))
22# A StrMethodFormatter is used automatically
23ax.zaxis.set_major_formatter('{x:.02f}')
24
25# Add a color bar which maps values to colors.
26fig.colorbar(surf, shrink=0.5, aspect=5)
27
28plt.show()
29