The example code is below.
import matplotlib.pyplot as plt
# x and y data as same length lists
radius = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
area = [3.14159, 12.56636, 28.27431, 50.26544, 78.53975, 113.09724]
plt.plot(radius, area)
plt.xlabel('Radius')
plt.ylabel('Area')
plt.title('Area of a Circle')
# show grid lines
ax = plt.axes()
ax.grid(True)
# show plot window
plt.show()
No comments:
Post a Comment