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:

Matplotlib_labels.py

from matplotlib.figure import Figure from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg import tkinter as tk #-------------------------------------------------------------- fig = Figure(figsize=(12, 8), facecolor='white') #-------------------------------------------------------------- # axis = fig.add_subplot(111)   # 1 row,  1 column, only graph axis = fig.add_subplot(211)     # 2 rows, 1 column, Top graph #-------------------------------------------------------------- xValues = [1,2,3,4] ...

Get Python GUI Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.