Book Image

Python GUI Programming Cookbook

By : Burkhard Meier
Book Image

Python GUI Programming Cookbook

By: Burkhard Meier

Overview of this book

Table of Contents (18 chapters)
Python GUI Programming Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Placing labels on charts


So far, we have used the default Matplotlib GUI. Now we will create some tkinter GUIs using Matplotlib.

This will require a few more lines of Python code and importing some more libraries, and it is well worth the effort, because we are gaining control of our paintings using canvases.

We will position labels onto both the horizontal as well as the vertical axes, aka x and y.

We will do this by creating a Matplotlib figure upon which we will draw.

We will also learn how to use sub plots, which will enable us to draw more than one graph in the same window.

Getting ready

With the necessary Python modules installed and knowing where to find the official online documentation and tutorials, we can now carry on with our creation of Matplotlib charts.

How to do it...

While plot is the easiest way to create a Matplotlib chart, using Figure in combination with Canvas creates a more custom-made graph, which looks much better and also enables us to add buttons and other widgets to it...