Matplotlib
- xlabel
- ylabel
- title
- plot
- show
1
import matplotlib.pyplot as plt
1
2
x = [1,2,3,4,5] # horizontal, independent variable
y = [1,2,3,4,5] # vertical, dependent variable
1
2
plt.plot(x,y)
plt.show()
1
2
3
4
5
plt.xlabel('X')
plt.ylabel('Y')
plt.title('Graph to show the effect of X on Y')
plt.plot(x,y)
plt.show()
1
2
3
4
5
6
7
8
ad_budget = [1,10,50,100,1000] #x-axis
sales = [10,100,500,1000,10000] #y-axis
plt.xlabel("Amount spent on ads ($)")
plt.ylabel("Amount of sales ($)")
plt.title("Graph to show the effects of ad budgeting on sales")
plt.plot(ad_budget, sales)
plt.show()