Data Visualisation with Chartify
Last Updated :
10 Jul, 2020
Chartify is an open-source data visualization library from Spotify that makes it easy for data analysts to create charts and graphs. Chartify is built on top of Bokeh, which is a very popular data visualization library. This article gives a brief introduction to this technology.
Modules Needed
Install the latest version of Chartify and Pandas. To install these modules type the below command in the terminal.
pip install chartify
pip install pandas
Pandas is required for data cleaning and manipulation in this context. So let’s import these on to our Python code. It is recommended to use the Jupyter notebook or Google Colab for any kind of data visualization or analysis.
Python3
import chartify
import pandas as pd
|
Chartify makes it very easy for anyone to start up. The following code helps set up a simple chart and displays it in the notebook.
Python3
ch = chartify.Chart()
ch.show()
|
Output:

However, this is just an empty chart with no data in it. Let’s try to fill this chart with data to see this visualization tool come alive. Chartify comes with its own dataset examples that you can use to learn from. Thus we are going to load the example data and display it.
Python3
data = chartify.examples.example_data()
data.head()
|

data.head()
If we analyze this dataset, we can come to the conclusion that it is time-series data. Time(or date), by convention, is displayed on the X-axis. Thus, let’s set the type of the X-axis to DateTime.
Python3
ch = chartify.Chart(x_axis_type = 'datetime' )
|
Now there are various kinds of plots you can draw with this tool. However, in this article we are going to use only two, that is, scatter plot and histogram.
First, let’s build a scatter plot. The easiest way to do this is by using the scatter method. The arguments that should be passed are the data_frame which has the data to be plotted, x_column which specifies X-axis and y_column which specifies Y-axis. All other arguments are optional(that is, a default value is assigned to them when not specified). The color_column argument colors the plot of the basis of the column specified. Let’s say in the above dataset we set color_column to be the column “fruit”. Chartify assigns different colors to different fruit names in the column. A list of values within the color_column argument is used for specific sorting of the colors. alpha is the transparency(alpha value) of a plot. Here 1.0 is completely opaque, which 0.0 is completely transparent. marker refers to the mark on the plot for values. The markers can be a circle, asterisk, diamond, triangle, and various other shapes.
Syntax: scatter(data_frame, x_column, y_column, size_column=None, color_column=None, color_order=None, alpha=1.0, marker=’circle’)
Now let’s set the title, subtitle, and other attributes for our chart.
Python3
ch.set_title( "Quantity Fruit vs Date" )
ch.set_subtitle( "Quantity of fruits grown all around the world" )
ch.axes.set_xaxis_label( "Date" )
ch.axes.set_yaxis_label( "Quantity" )
ch.set_source_label( "Source:Chartify Examples" )
|
Now let’s make a scatter plot using the following and display it onto the notebook. data or the example dataset we got from Chartify will be our data_frame. The X-axis will be date and Y-axis will be quantity. The color_column will be fruit.
Python3
ch.plot.scatter(data_frame = data, x_column = 'date' ,
y_column = 'quantity' ,
color_column = 'fruit' )
ch.show()
|
Output:

Scatter Plot
Thus, we have built a simple scatter plot. Now let’s make a histogram using the same dataset. Let’s plot a histogram that visualizes the density of data with respect to quantity.
Python3
ch = chartify.Chart(y_axis_type = 'density' )
|
To plot the histogram we are going to use the histogram method. Just like the scatter plot, even the histogram takes in a data_frame argument. color_column and color_order work in the same way as it did in the scatter plot. The method argument takes in a method and calculates the density of the graph on that basis. The count is the default method.
Syntax: histogram(data_frame, values_column, color_column=None, color_order=None, method=’count’, bins=’auto’)
Now let’s set the attributes of our chart.
Python3
ch.set_title( "Quantity vs Count" )
ch.axes.set_xaxis_label( "Quantity" )
ch.axes.set_yaxis_label( "Count" )
ch.set_source_label( "Source:Chartify Examples" )
|
Now let’s plot the histogram using the method mentioned earlier.
Python3
ch.plot.histogram(data_frame = data, values_column = 'quantity' )
ch.show()
|
Output:

Histogram
Thus, in this article, we have plotted a histogram and a scatter plot using Spotify’s Chartify. This is just a beginner article and the same knowledge can be extended further to build more complex visualizations.
Similar Reads
Data Visualization With Altair
Nowadays, Data is an important entity. It should be processed in such a way so that the companies can understand the psychology of the consumers. Data visualization is an important step in processing of data. Altair is a declarative statistical visualization library for Python, built on Vega and Veg
9 min read
Data visualization With Pygal
Pygal is an open-source Python library designed for creating interactive SVG (Scalar Vector Graphics) charts. It is known for its simplicity and ability to produce high-quality visualizations with minimal code. Pygal is particularly useful for web applications, as it integrates well with frameworks
10 min read
What is Big Data Visualization?
Volume, variety, and velocity (3 V's) of data has been generating rapidly and posing significant challenges for organizations to seek and extract actionable insights. Here, Big Data Visualization offers the means to transform massive and complex datasets into comprehensible and insightful visual rep
10 min read
Power BI - Data Visualization With Multiple Charts
Sometimes while dealing with hierarchical data we need to combine two or more various chart types into a single chart for better visualization and analysis. These are known as âCombination chartsâ. In this article, we are going to see how to combine a stacked column chart and a line chart in Power B
9 min read
What is a Data Visualization Dashboard?
Businesses and organizations are continuously looking for ways to make sense of the enormous volumes of data they generate and gather in this era of information overload. Organizations gain crucial insights and patterns that might otherwise go unnoticed by converting data into visual representations
15+ min read
Data Visualization with Highcharter in R
Highcharter is an R package that provides an interface to the Highcharts JavaScript library, enabling the creation of interactive and customizable charts. It supports a variety of chart types, such as line, bar and scatter charts and offers extensive customization options for appearance and behavior
5 min read
Charts and Graphs for Data Visualization
As companies and groups deal with more and more data, itâs crucial to present it visually. Data is everywhere these days, and it can be overwhelming. This article is your guide to Data Visualization, which is turning all that data into pictures and charts that are easy to understand. Whether you wor
13 min read
Getting started with Data Visualization in R
Data visualization is the technique used to deliver insights in data using visual cues such as graphs, charts, maps, and many others. This is useful as it helps in intuitive and easy understanding of the large quantities of data and thereby make better decisions regarding it. Data Visualization in R
6 min read
What is Interactive Data Visualization?
Organizations are always looking for innovative methods to effectively share insights and get value from their data in today's data-rich environment. With dynamic and engaging images, users may explore and comprehend data thanks to the potent interactive data visualization technology. The article ai
9 min read
Data Visualization for Business
It is the portrayal of any data in the form of chart, graphs, images, examples etc. It is used not only in one sector but in many sectors. Due to an increase in statistical data, visual representation of that data is appreciated rather than going through spreadsheets. It is easy to understand as wel
4 min read