In this post I am going to discuss a Matplotlib feature which let you add multiple plots within a figure called subplots. Subplots are helpful when you want to show different data presentation in a single view, for instance Dashboards. There are multiple ways you can create subplots but I am here going to discuss the one which let you add graphs in grids by using subplot2grid method. subplot2grid takes two mandatory parameters, the first one is size and the next is location. A typical subplot2grid call will look like below: ax = plt.subplot2grid((2, 2), (0, 0)) The first parameter is the size that is a 2 x 2 grid, the 2nd is…
-
-
Data Visualization in Python – Pie charts in Matplotlib
In last post I discussed scatter, today I am going to discuss Pie charts. What are Pie Charts? An Emma chart (or a circle chart) is a circular statistical graphic which is divided into slices to illustrate numerical proportion. In a pie chart, the arc length of each slice (and consequently its central angle and area), is proportional to the quantity it represents. While it is named for its resemblance to a pie which has been sliced, there are variations on the way it can be presented. The earliest known pie chart is generally credited to William Playfair’s Statistical Breviary of 1801.[1][2] Pie charts are good to show proportional…
-
Data Visualization in Python – Scatter plots in Matplotlib
In last post I talked about plotting histograms, in this post we are going to learn how to use scatter plots with data and why it could be useful. What is Scatter Plot? From Wikipedia: A scatter plot (also called a scatterplot, scatter graph, scatter chart, scattergram, or scatter diagram)[3] is a type of plot or mathematical diagram using Cartesian coordinates to display values for typically two variables for a set of data. If the points are color-coded, one additional variable can be displayed. The data are displayed as a collection of points, each having the value of one variable determining the position on the horizontal axis and the value…
-
Data Visualization in Python – Histogram in Matplotlib
In the last post I talked about bar graphs and their implementation in Matplotlib. In this post I am going to discuss Histograms, a special kind of bar graphs. What is Histogram? From Wikipedia A histogram is an accurate graphical representation of the distribution of numerical data. It is an estimate of the probability distribution of a continuous variable (quantitative variable) and was first introduced by Karl Pearson. It is a kind of bar graph. To construct a histogram, the first step is to “bin” the range of values—that is, divide the entire range of values into a series of intervals—and then count how many values fall into each…
-
Data Visualization in Python – Bar Graph in Matplotlib
In last post I covered line graph. In this post I am going to show how to draw bar graph by using Matplotlib. Bar Graph What is bar graph? According to Wikipedia A bar chart or bar graph is a chart or graph that presents categorical data with rectangular bars with heights or lengths proportional to the values that they represent. The bars can be plotted vertically or horizontally. So in short, bar graphs are good if you to want to present the data of different groups that are being compared with each other. For this post I have picked the data of movies genres released from 1995-2017. The source of data is here. import matplotlib.pyplot as plt import numpy…
-
Data Visualization in Python – Line Graph in Matplotlib
I recently covered data gathering via scraping. Now I am going to cover how the data can be visualized. The best way to do is to plot graphs. Graphs makes it easier to see the relation between a data variable with other. There are various kinds of graphs available: Line, Bar, Chart, Histogram etc. Since we are dealing in Python, it provides a very good library for plotting cool graphs. It’s called Matplotlib. From the Official Site: Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. Installation The best way to install it by using…
-
Structures and Methods in Go
In this post I am going to discuss Go lang’s another features, structs As I told earlier that Go is not a typical Object Oriented Language. Structures is kind of answers of what you do with Classes and objects. Well, Structure is not a special concept to Go only. If you have worked on C language then you could have an idea what is it all about. Let’s write a simple program package main import "fmt" type person struct { name string age int height float64 weight float64 } func (p person) get_info() { fmt.Println("Name:- " + p.name) fmt.Println("Age:- ", p.age,"years ") fmt.Println("Height:- ", p.height,"cm") fmt.Println("Weight:- ", p.weight,"KG") } func…
-
Implementing beanstalk to create a scaleable web scraper
Image Credit (http://blog.hqc.sk.ca/wp-content/uploads/2012/12/Queue-2012-12-11.jpg) Queues are often used to make applications scaleable by offloading the data and process them later. In this post I am going to use BeansTalk queue management system in Python. Before I get into real task, allow me to give a brief intro of Beanstalk. What is Beanstalk? From the official website: Beanstalk is a simple, fast work queue. Its interface is generic, but was originally designed for reducing the latency of page views in high-volume web applications by running time-consuming tasks asynchronously. It’s demon called beanstalkd which you can run on *nix based machines. Since I am on OSX so I called brew install beanstalkd to install it. Once…
-
Let’s Go:: A very brif introduction to Go language
Hello World I am back! I know it took *a bit* long resuming this blog as I got pretty busy in other stuff related to my work. Alright so this post is about writing applications in Go, a programming language create at Google by Ken Thompson(“K” from famous K&R) and the creator of Unix and Rob Pike. I had not thought of learning another programming but there a few reasons I go for the Go Go is a minimal language like Python. Since it was developed by Googlers who are also Python lovers, they came up a language which is simple to write like Python but more efficient like…
-
Develop database driven applications in Python with Peewee
It is not uncommon that most of the applications these days are interacting with database these days. Specially with RDBMS based engines( DB engines that support SQL). Like any other languages Python also provides native and 3rd party libraries to interact with database. Normally you have to write SQL queries for CRUD operations. That’s OK but at times it happens that things get messy: The Big Boss decided to move from MySQL to.. MSSQL and you have no choice but to nod at him and making changes in your queries compatible with other Db Engine. You gotta make multiple queries just to retrieve a single piece of info from the…