Data Visualization With Python

 In today’s world, a lot of data is being generated on a daily basis which becomes very difficult to handle and make out a better observation. It becomes more difficult when the data is in its raw format. To get the better view and understanding of the particular data we use data visualization as a tool to tackle the problem.

 Data visualization provide us a good overview and pictorial representation, understanding of the large scale of data.

In this article we will discuss how to visualize the data.



Python comes with different libraries to visualize the data. Each library have different features to work with and can support various types of graphs. In this blog we will discuss about the different libraries used to represent the data set.

These libraries are: 

  • Matplotlib
  • Seaborn
  • Plotly
We will discuss the library one by one. Before plotting the data we should prepare our data set to get accurate plotting.
Create the environment for the data plotting.

Matplotlib

Matplotlib is one of the most commonly used library which helps us to represent the data into 2D plots of array. It is a multi platform library based on numpy. We can visualize the data using different plots like scatter plot, line plot, histogram, etc. Matplotlib provides a lot of flexibility. 

You can install matplotlib using command

!pip install matplotlib

Now we will see some commonly used plots using this library.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
  
** We import pandas to read the data set.
** Numpy is used to perform mathematical operations
** Matplotlib used for visualization

  
# reading the database
data = pd.read_csv("../input/net-flix/netflix_titles.csv")

After reading the data we will set up the environment of data to get the
proper visualization.

You can refer the attached link to set the data for a good understanding
and visualization,

1. Bar Chart

  Bar chart is the type of graph that represent the data vertically or horizontally. It can represent the discreet categories. It involves both axis X and Y which helps to represent the data into a pictorial for to have a better view or to understand the data into particular group vise and period wise. We use bar() function to represent the data

#Now Plot graph

plt.bar(Data['rating'],Data['year_added'])

plt.rcParams['figure.figsize']=(10,8)

plt.title('Release Year vs Rating effect')

plt.xlabel('Rating')

plt.ylabel('Year')

plt.show()


Output: 





2. Line Chart

It is used to represent the relationship between with two different data on X and Y axis. which is represent by line graph.

import seaborn as sns
sns.lineplot(Data['type'],Data['duration'])
plt.title('Netflix vs duration graph')
plt.show()
 

3. Histogram

A histogram is a graphical representation which helps us to plot the data into particular range. We can say into frequency range. To use this graph our data shou ld be in numeric form. We use the hist() function to represent the data into Histogram.



4. Scatter Plot

In scatter plot relationship between data is represent in the dot format. Scatter () method in the matplorlib library is used to plot the data. We can identify the data of different group using different colour also.
 
You can go through the coding parts from the mention link:

Seaborn


Seaborn is also one of the most commonly used and advance label library to represent the data using different graphs. It provides a high-level interface for drawing attractive and informative statistical graphics. It is the advance way of representing data in more attractive way. It is the similar library like matplotlib but the difference is its helps user to get more attractive and effective visualization using modern technologies. 
Install seaborn as
!pip install seaborn

We can plot all the above mention graph using seaborn library also.
1. Bar graph
2. Scatter plot
3. Line graph
4. Histogram
5. Violin plot
6. Pie chart
7. Box Plot

So many more.


Violin plot:
A violin plot is a method of plotting numeric data. It is almost similar to box plot with the addition of rotated kernel density plot at each side.



Box Plot:
A box and whisker plot is defined as a graphical method of displaying variation in a set of data. In most cases, a histogram analysis provides a sufficient display, but a box and whisker plot can provide additional detail while allowing multiple sets of data to be displayed in the same graph.

plt.figure(figsize=(10,10))
sns.boxplot(x="features", y="value", hue="diagnosis", data=data)
plt.xticks(rotation=90)


Pie Chart:

It is a type of chart which display the data in the form of circular statical graph. Its help to represent the numeric data and percentage of that.



For better understanding you may refer the mention link:

PLotly
It is most open source data visualization tool. It helps to create interactive charts for web browser and also support many languages such as Python, R, Julia and Matlab. We can also use this with other programing language. It is helps in creating dashboard. It is more suitable to creating elaborating plots more effectively.


Same above mention graphs we can represent with plotly also



Comments