0% found this document useful (0 votes)
5 views6 pages

Working With The Matplotlib Chart in Python

The document provides a guide on using the Matplotlib library in Python for creating charts. It includes instructions for installation, plotting data with titles and axis labels, comparing multiple datasets, applying styles, and adding legends. Each section contains example code snippets to demonstrate the functionalities of Matplotlib.

Uploaded by

Dhruvee Vadhvana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Working With The Matplotlib Chart in Python

The document provides a guide on using the Matplotlib library in Python for creating charts. It includes instructions for installation, plotting data with titles and axis labels, comparing multiple datasets, applying styles, and adding legends. Each section contains example code snippets to demonstrate the functionalities of Matplotlib.

Uploaded by

Dhruvee Vadhvana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Working with the Matplotlib chart in python

Installation of matplotlib library


%matplotlib inline
from matplotlib import pyplot as plt
plt.plot([1,2,3],[2,5,7])
plt.show()

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

from matplotlib import pyplot as plt


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()
Using Style 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)
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()

You might also like