top of page

Matplotlib library in python for Data Science and Data Visualization?

Updated: Aug 7, 2020

Matplotlib library is open source library for data mining and data visualization. Matplotlib library is rich of functions which will reduce the effort. In this blog I am going to share few basic function which will gives you a general understanding. Below are the goals of this blog:


  • You will able to draw Graphs, scatters, pie-charts, Histograms etc.

  • You will be able to customize these charts and graphs with different parameters.

  • You will gain the basic terminology for python and Data Science.

  • You will build your own customized Charts, Graphs, Scatters etc.

Let’s Start with the basic introduction of Matplotlib Library. We all know that we understand things better when we see things visualized. So this library will help to visualize the data and information for better understanding.


1. Simple Graph 2. Scatter 3. Histogram 4. Pie-charts 5. Basic Customization

Simple Graph

First of all , here I am going to explain how to build a graph using specific data I have a data of market sale of a product which is containing number of different information parameters. One of them is Total Profit corresponding to the specific regions.

Let’s Start

Import library Mateplotlib using command “import matplotlib.pyplot as plt”

  • Unitp refers for unit prize of product

  • Tprofit refers for total profit of product

  • unit_price = pd.read_csv("dataset.csv", usecols=unitp) (Reading the data from dataset.csv with               unit prize column via “usecol” command)

  • Total_Profit = pd.read_csv("dataset.csv", usecols=tprofit)( Reading the data from dataset.csv                   with total profit column via “usecol” command)

Next just plot the graph using mentioned commands; here I have plotted x-axis unit prize and y-axis as Total profit. This should be look like provided graph.



Scatters


Next one is scatters , Here every data point has shown by dot only, No any data point represent by line. Let’s take one more example.

If you just replace the function plt.plot() with plt.scatter(unit_price, Total_Profit) the graph will move to scatters.

Histogram

One more interesting function is Histogram , Let’s direct goes to diagram for quick understanding, I think now you get that “how functions are work by calling them using different parameters”


Now here I am just calling plt.hist() for plotting a histogram.




Basic Customization

  1. plt.xlabel

  2. plt.ylabel

  3. plt.title

Here we have few functions for customization function to make your graph attractive and more understandable.


And you can find changes as


Hope you have satisfied with provided information, this is sufficient for begin. I suggest keep trying to make your own graphs and charts to explore the data with valuable results. I will also share some examples with complete data analysis techniques.


I am posting here complete example for better understanding, might be it will useful to you. Apart from that, you can more Data science python blogs in my recent blogs or my blog section.




Thanks for reading! Your opinions are valuable for me. So please comment in below section to improve the quality of information.

Share and care: Technology Spiritual


 
 
 

Recent Posts

See All

Comentarios


bottom of page