An introduction one of the more stylish Python plotting libraries.
![Python in a coffee cup.][1]
[Python][2] is full of libraries that can visualize data.One of the more interactive options comes fromPygal, which I consider the library for people who like things to look good. It generates beautiful SVG (Scalable Vector Graphics) files that users can interact with.SVG is a standard format for interactive graphics, and it can lead to rich user experiences with only a few lines of Python.
### Using Pygal for stylish Python plots
In this introduction, we want to recreatethis multi-bar plot, which represents the UK election results from 1966 to 2020:
![Pygal plot][3]
Before we go further,note that you may need to tune your Python environment to get this code to run, including the following.
* Running a recent version of Python (instructions for[Linux][4],[Mac][5], and[Windows][6])
* Verify you're running a version of Python that works with these libraries
The data is available online and can be imported using pandas:
Plotting this in Pygal builds up in a way that I find easy to read. First, we define the style object in a way that will simplify our bar chart definition. Then we pass the custom style along with other metadata toa `Bar` object:
The result is an interactive SVG plot you can see in this gif:
![The Python pygal library can generate rich SVG files as seen here][7]
Beautifully simple, and with beautiful results.
### Conclusion
Some plotting options in Python require building every object in great detail, and Pygal gives you that functionality from the start. Give Pygal a go if you have data on hand and you want to make a clean, beautiful, and simple plot for user interaction.
\---
_This article was first shared[here][8] and is edited and republished with permission._