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')
Our graph is ready now but it's kind of naked (without labels ;) ) but let's show it!

plt.show()

But a graph with no labels would make no sense to anyone hence it's our duty to make sure that the graph's x-axis and y-axis are labelled correctly. Let's add them too!

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.

{ 1 comments... read them below or add one }

  1. Lucky Club | Slots & Live Casino Site
    Lucky 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

    ReplyDelete

Popular Post

Blogger templates

Total Pageviews

Powered by Blogger.

- Copyright © nulldata -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -