Skip to content

Latest commit

 

History

History

matplotlib

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Many times it is required to embed matplotlib with Qt since it allows to use many more types of widgets or to use the other Qt modules. And fortunately matplotlib provides Qt as a backend, but unfortunately the official examples (see official example here) are limited so this post will try to provide examples and basic tips on how both libraries should interact.

The following rules are basic:

  • The binding (PyQt5 or PySide2) must be imported first so that matplotlib that library must use internally.

  • You should not use matplotlib.pyplot but Figure to manipulate the painting and the FigureCanvas as a widget.

Many functions or classes accept an AxesSubplot as a parameter (with the argument "ax") so it must be used to point to the axis where it should be drawn.

Sample plots

Example Link
Simple Plot https://matplotlib.org/gallery/lines_bars_and_markers/simple_plot.html
Multiple subplots https://matplotlib.org/gallery/subplots_axes_and_figures/subplot.html
Image Demo https://matplotlib.org/gallery/images_contours_and_fields/image_demo.html
pcolormesh https://matplotlib.org/gallery/images_contours_and_fields/pcolormesh_levels.html
Demo of the histogram (hist) function with a few features https://matplotlib.org/gallery/statistics/histogram_features.html
PathPatch object https://matplotlib.org/gallery/shapes_and_collections/path_patch.html
3D surface (color map https://matplotlib.org/gallery/mplot3d/surface3d.html
Streamplot https://matplotlib.org/gallery/images_contours_and_fields/plot_streamplot.html
Ellipse Demo https://matplotlib.org/gallery/shapes_and_collections/ellipse_demo.html
Percentiles as horizontal bar chart https://matplotlib.org/gallery/statistics/barchart_demo.html
Basic pie chart https://matplotlib.org/gallery/pie_and_polar_charts/pie_features.html
Table Demo https://matplotlib.org/gallery/misc/table_demo.html
Scatter Demo2 https://matplotlib.org/gallery/lines_bars_and_markers/scatter_demo2.html
Filled polygon https://matplotlib.org/gallery/lines_bars_and_markers/fill.html
Date tick labels https://matplotlib.org/gallery/text_labels_and_annotations/date.html
Log Demo https://matplotlib.org/gallery/scales/log_demo.html
Polar Demo https://matplotlib.org/gallery/pie_and_polar_charts/polar_demo.html
Legend using pre-defined labels https://matplotlib.org/gallery/text_labels_and_annotations/legend.html
Mathtext Examples https://matplotlib.org/gallery/text_labels_and_annotations/mathtext_examples.html
Rendering math equation using TeX https://matplotlib.org/gallery/text_labels_and_annotations/tex_demo.html
Subplot example https://matplotlib.org/tutorials/introductory/sample_plots.html#subplot-example

matplotlib widgets

In this section I show the translation of the official examples of the matplotlib widgets from matplotlib.pyplot to Qt.

Widget Link
buttons https://matplotlib.org/examples/widgets/buttons.html
check_buttons https://matplotlib.org/examples/widgets/check_buttons.html
cursor https://matplotlib.org/examples/widgets/cursor.html
lasso_selector_demo https://matplotlib.org/examples/widgets/lasso_selector_demo.html
menu https://matplotlib.org/examples/widgets/menu.html
multicursor https://matplotlib.org/examples/widgets/multicursor.html
radio_buttons https://matplotlib.org/examples/widgets/radio_buttons.html
rectangle_selector https://matplotlib.org/examples/widgets/rectangle_selector.html
slider_demo https://matplotlib.org/examples/widgets/slider_demo.html
span_selector https://matplotlib.org/examples/widgets/span_selector.html