Book Image

Matplotlib 3.0 Cookbook

By : Srinivasa Rao Poladi, Nikhil Borkar
Book Image

Matplotlib 3.0 Cookbook

By: Srinivasa Rao Poladi, Nikhil Borkar

Overview of this book

Matplotlib provides a large library of customizable plots, along with a comprehensive set of backends. Matplotlib 3.0 Cookbook is your hands-on guide to exploring the world of Matplotlib, and covers the most effective plotting packages for Python 3.7. With the help of this cookbook, you'll be able to tackle any problem you might come across while designing attractive, insightful data visualizations. With the help of over 150 recipes, you'll learn how to develop plots related to business intelligence, data science, and engineering disciplines with highly detailed visualizations. Once you've familiarized yourself with the fundamentals, you'll move on to developing professional dashboards with a wide variety of graphs and sophisticated grid layouts in 2D and 3D. You'll annotate and add rich text to the plots, enabling the creation of a business storyline. In addition to this, you'll learn how to save figures and animations in various formats for downstream deployment, followed by extending the functionality offered by various internal and third-party toolkits, such as axisartist, axes_grid, Cartopy, and Seaborn. By the end of this book, you'll be able to create high-quality customized plots and deploy them on the web and on supported GUI applications such as Tkinter, Qt 5, and wxPython by implementing real-world use cases and examples.
Table of Contents (17 chapters)

Using the Slider and Button Widgets of Matplotlib

We learned about the Button widget of Matplotlib in the previous chapter, but Slider is a new widget that we will learn here. However, the objective of this recipe is to demonstrate how a Matplotlib widget application can be used across GUI frameworks without any code changes, by just changing the backend. We will also use the same polar plot across all the GUI frameworks, so that we can see the difference in the way they work, rather than getting lost in the details of the plot itself!

We will use the Slider to determine the number of leaves to be plotted in the polar plot. Each time the Slider is dragged, the value of the Slider is taken to plot that many leaves in the plot.

We will use the Quit Button to exit the application by closing the figure and window objects.

...