Working With The Matplotlib Chart in Python
Working With The Matplotlib Chart in Python
output
Including Title and axis
%matplotlib inline
from matplotlib import pyplot as plt
plt.plot([1,2,3],[2,5,7])
plt.title("mydata")
plt.ylabel("Y")
plt.xlabel("X")
plt.show()
In single plot need to plot comparison data
plt.plot(x,y)
plt.plot(x2,y2)
plt.show()
Using Style in chart
style.use('ggplot')
x=[1,5,4]
y=[23,33,40]
x2=[3,7,4]
y2=[8,7,3]
plt.plot(x,y)
plt.plot(x2,y2)
plt.show()
Adding Label in chart
from matplotlib import pyplot as plt
from matplotlib import style
style.use('ggplot')
x=[1,5,4]
y=[23,33,40]
x2=[3,7,4]
y2=[8,7,3]
plt.plot(x,y, label="first")
plt.plot(x2,y2, label="second")
plt.legend()
plt.show()