Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing attractive statistical graphics.
import matplotlib.pyplot as plth
matplotlib can also output charts in other formats like image files.
plt.bar(range(len(counts)), counts.values(), align='center')
Bar code : Use below python code to generate bar Graph to display the vote counts from the radish variety program
plt.show()
Here the graph with no information of x and y axis is of no use, So to label x-axis and y-axis from which we can extract the information or observations
Bar Plot of Radish Votes:
Let's see how to generate bar plot of the data.We will display the individual counts of radish variety across the
Let's see how to generate bar plot of the data.We will display the individual counts of radish variety across the
data.
matplotlib to generate a bar graph
import matplotlib.pyplot as plth
matplotlib can also output charts in other formats like image files.
plt.bar(range(len(counts)), counts.values(), align='center')
Bar code : Use below python code to generate bar Graph to display the vote counts from the radish variety program
plt.show()
Here the graph with no information of x and y axis is of no use, So to label x-axis and y-axis from which we can extract the information or observations
plt.ylabel(s = "Votes") plt.xticks(range(len(counts)), counts.keys(),rotation=90)
We create a range of indexes for the X values in the graph, one entry for each entry in the "counts" dictionary (ie len(counts)
), numbered 0,1,2,3,etc.This will spread out the graph bars evenly across the X axis on the plot.
np.arange
is a NumPy function like therange()
function in Python, only the result it produces is a "NumPy array".plt.xticks()
specifies a range of values to use as labels ("ticks") for the X axis.x + 0.5
is a special expression because x is a NumPy array. NumPy arrays have some special capabilities that normal lists orrange()
objects don't have.The above part is from opentechschool.python tutorial.
Reference : http://opentechschool.github.io/python-data-intro/core/charts.html
No comments:
Post a Comment