Data Visualization
#Create Automatic Visualization with Matplotlib, Seaborn.
We can create charts in python by following ways:
- Plotting from Numpy.
- From DataFrames.
- Using SeaBorn.
- Using d3j.
We have already discussed the basic understanding of plotting charts in our previous section. To brush up, please go to this link: Click here.
1. Here we are taking random number and doing the cumulative sum. Then select the color which is red 'r', selecting the dashed line which is 'k--' and alpha means contrast of the line.
#Plotting two or more charts in one chart:
Here fig.add_subplot() is the easiest way to divide an existing figure object into distinct regions of various sizes. It returns an axis and takes three integers. The first two arguments define the division of the figure and the last argument says where in that division the subplot should go.
Therefore, add_subplot(2,2,1) means to break the subplot into a 2X2 grid and place the new subplot in the first cell of that grid.
#Plotting on DataFrame:
This plotting has been done on DataFrame. The columns are A, B, C, D and index is from 0 to 100 with an increment of 10.
#Plotting Bar Graph in Horizontal and Vertical:
Here, we are creating figure and axes and subplotting 1 row and 2 columns. When we create subplot, we use axes[0] and axes[1]. Here, bar() means vertical and barh() means horizontal.
#Loop inside Loop in Plot Charts Impression:
Since it is subplot, we have to loop through the rows and cloumns to show below chart.
#Bar Plot:
The name of the column is one,two,three....
The name of the index is Genus and name of the column is A, B, C, D.
This is just a small introduction of how you can draw simple chart using Python matplotlib.
No comments:
Post a Comment