- Back to Home »
- bar graph , charts , data visualization , graphs , Hands-on , matplotlib , Python »
- Creating Charts using matplotlib in Python [Hands-on]
Posted by : Netbloggy
Sunday, August 9, 2015
Data Storytelling is a very important branch of Data Science. Your world may not be as fond of numbers as you are hence it's very important to show them your results in the language that they understand. Hence for any language to be a member of the data science world, it's not only their data processing capabilities should be great but also the data visualizations should be exceptional and hence Python with packages like matplotlib is capable of competing in the world of R.
So let's try to represent the data of our previous post in terms of graphs/charts.
Problem:
Draw a bar graph with a dictionary counts that we built in our previous blogpost.
Takeaways:
- Basics of matplotlib
Approach:
As we do for every new package, the first job is to import matplotlib package.
import matplotlib.pyplot as plt
Now let's draw a bar graph with the values (vote) of the dictionary counts
plt.bar(range(len(counts)), counts.values(), align='center')
plt.show()
plt.ylabel(s = "Votes") plt.xticks(range(len(counts)), counts.keys(),rotation=90)
And here's how the bar graph looks: beautiful isn't?
Download the source code here.
Lucky Club | Slots & Live Casino Site
ReplyDeleteLucky Club is a Swedish online casino and casino that offers an exceptional gaming experience for customers. Come and discover our exciting online casino Live Casino games: Roulette, Blackjack, Baccarat, Baccarat, 카지노사이트luckclub Baccarat Rating: 3.6 · 10 votes