Matplotlib : A plotting library for python
Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. It is said that “Matplotlib makes easy things easy and hard things possible”. It is a low-level library with a interface similar to Matlab which offers lots of freedom but at the cost of having to write more code.
pip install matplotlib
# in conda
conda install matplotlib
We will here see pyplot submodule in detail with plt as alias.
We can change the theme of our plot by choosing from available themes.
themes = plt.style.available
print(themes)OUTPUT['Solarize_Light2', '_classic_test_patch', 'bmh', 'classic', 'dark_background', 'fast', 'fivethirtyeight', 'ggplot', 'grayscale', 'seaborn', 'seaborn-bright', 'seaborn-colorblind', 'seaborn-dark', 'seaborn-dark-palette', 'seaborn-darkgrid', 'seaborn-deep', 'seaborn-muted', 'seaborn-notebook', 'seaborn-paper', 'seaborn-pastel', 'seaborn-poster', 'seaborn-talk', 'seaborn-ticks', 'seaborn-white', 'seaborn-whitegrid', 'tableau-colorblind10']plt.style.use("dark_background")
Line Plot
Here we plotted x and y on their respective axes . We can also plot many equations at a single time.
When plt.show() is exceuted then lines are plotted if we want two different graphs then →
Lets make a perfect line plot by putting some addons also like title ,labels colours. plt.legend() lets us print label.
Scatter Plot
It is similar to line plot except to the fact that we will be plotting points not lines.
Bar Graph
It’s very simple to plot a bar graph by executing the following command.
Piechart
Following code helps us draw the pie chart. If you don’t want anyone subject to be highlighted then skip the explode term. shadow = True gives us the better effects.
HISTOGRAM
A histogram is an accurate representation of the distribution of numerical data. It is an estimate of the probability distribution of a continuous variable. It is a kind of bar graph.
Don’t forget to refer official documentation
There can be many more things to be done. So do explore them and play around visualizing data!!!