The Python Graph Gallery

Welcome to the Python Graph Gallery, a website that displays hundreds of python charts with their reproducible code snippets.



By Yan Holtz, Queensland Brain Institute of Brisbane

Python is currently the leading programming language in the field of data science, followed close by R [ref: KDnuggets]. Data visualization is a key step in this area, and Python offers great possibilities when it comes to representing your data graphically. However, the huge number of tools and the potential complexity of the documentation makes it difficult to build a desired chart.

The Python Graph Gallery is a website that displays hundreds of graphics made with python, always providing a reproducible code snippet.

400 graphics and 40 sections

The gallery currently provides about 400 distinct charts organized in 40 sections. Each section is represented by a logo made by designer Conor Healy. The color depends of the topic of the graphic: distribution, correlation, part of a whole, maps, flow, evolution… This classification is inspired from the graphic continuum and should allow you to quickly find the chart you need.

Python Graph Gallery 1

Of course, most common plot types like barplot, scatterplot, boxplot or histograms are present. But some less common data visualization types are present as well, like lollipop plot, bubble plot, 2D density plot or wordclouds.

From easy to tricky

Once you enter a chart section, several examples are displayed, from the easiest to the hardest. Usually, the first example describes how the input dataset must be formatted, and how to make the graphic using the default parameters. Explanations are provided, code is shortened to its strict minimum and commented line by line, this makes it easy to understand how the function works. Here is an overview of the most simple density plot you can do:

Progressively, examples lead you from a very basic version to highly customized charts. Each example aims to explain one particular tip, like customizing colours, flipping axes, adding several groups and so on. At the end of the section, you will find some ‘real life examples’ combining all these tips to get a nice customized figure.

Python Graph Gallery 3

A focus on Matplotlib and Seaborn

A bunch of libraries exist when it comes to making charts with python. I decided to rely mainly on Matplotlib and Seaborn, these are currently the main 2 tools used. Almost every type of chart is feasible with them. When it is not, I used other libraries like folium for maps or networkX for networks.

Note that both Matplotlib and Seaborn have a dedicated page showing tips generic to every type of chart, like customizing axes and titles, calling different themes, controlling colours... These pages can be useful to quickly find again the every-day code snippets that we tend to forget.

Python Graph Gallery 4

Visit this link here for the code.

Conclusion
The Python Graph Gallery displays hundreds of graphics and can hopefully help you to quickly realise the chart you need. In this sense, it mainly aims to help users on a technical point of view.

However, the goal is also to increase the knowledge of users in the field of data visualization:

  • By visiting the website, you may discover new type of dataviz options that could fit your data
  • Each section is introduced by a short description explaining when the chart type is advised
  • A bad chart section is sometimes included at the bottom of a section, warning you about the common mistakes made on this type of chart

The gallery is a project developed by Yan Holtz during his nights and holidays. Thus, please be indulgent concerning bugs, imprecisions and English language mistakes. Any bug or feedback is strongly welcome at yan.holtz.data@gmail.com or via twitter: @R_Graph_Gallery. Last but not least, note that the Python graph gallery has a twin sister: the R graph gallery.

Author Bio

Yan Holtz is a passionate data analyst and bioinformatician currently working for the Queensland Brain Institute of Brisbane.  He has a special attraction for data visualization which lead him to build the R and the Python graph galleries. He can be reached at: yan.holtz.data@gmail.com.

Homepage: https://holtzyan.wordpress.com/

Related: