Matplotlib Package
Matplotlib Package
Data Visualization is one of the key skills required for data scientists. There are
many tools available for visualizing the data graphically. One such tool for
python developers is matplotlib.
Matplotlib is open-source cross-platform python library used for Data
visualization and Graphical plotting.
Installing Matplotlib:
For installing matplotlib in windows, press win+R and type cmd and click enter.
in the command prompt type, the following command:
pip install matplotlib
For Linux users, press ctrl+alt+T to open the Terminal. And type the following
command:
sudo apt-get install python3-matplotlib
# Dataset
courses = ['Python', 'Java', 'C++', 'C']
values = [24, 12, 6, 18]
Output:
Scatter plot: Use scatter() method to do scatter plot
4. Generating a scatter plot with Matplotlib in Python
import matplotlib.pyplot as plt
# Dataset
x = [2, 3, 4, 6, 7, 9, 8, 9, 8, 12]
y = [34, 65, 34, 60, 83, 45, 67, 87, 78, 90]
# Creating a scatter plot with color specified using the color parameter
plt.scatter(x, y, color="blue")
Output:
Pie chart: It is plotted using plt.pie().
A pie chart is a visual representation used to show the proportion of different
categories in a dataset. It divides a circle into slices, with each slice
representing a category and its size showing the proportion of that category
relative to the whole. Pie charts are useful for quickly understanding the
relative sizes of different categories in a dataset, making them popular for
displaying categorical data.
# dataset
count = [35, 25, 25, 15]
lang = ["Python", "Java", "C++", "C"]