matplotlib.pyplot.show#
- matplotlib.pyplot.show(*, block=None)[source]#
Display all open figures.
- Parameters:
- blockbool, optional
Whether to wait for all figures to be closed before returning.
If
True
block and run the GUI main loop until all figure windows are closed.If
False
ensure that all figure windows are displayed and return immediately. In this case, you are responsible for ensuring that the event loop is running to have responsive figures.Defaults to True in non-interactive mode and to False in interactive mode (see
pyplot.isinteractive
).
See also
Notes
Saving figures to file and showing a window at the same time
If you want an image file as well as a user interface window, use
pyplot.savefig
beforepyplot.show
. At the end of (a blocking)show()
the figure is closed and thus unregistered from pyplot. Callingpyplot.savefig
afterwards would save a new and thus empty figure. This limitation of command order does not apply if the show is non-blocking or if you keep a reference to the figure and useFigure.savefig
.Auto-show in jupyter notebooks
The jupyter backends (activated via
%matplotlib inline
,%matplotlib notebook
, or%matplotlib widget
), callshow()
at the end of every cell by default. Thus, you usually don't have to call it explicitly there.
Examples using matplotlib.pyplot.show
#
Animated image using a precomputed list of images
HBoxDivider and VBoxDivider demo
Show RGB channels using RGBAxes
Control the position and size of a colorbar with Inset Axes
Per-row or per-column colorbars
Axes with a fixed physical size
ImageGrid cells with a fixed aspect ratio
Make room for ylabel using axes_grid
Align histogram to scatter plot using locatable Axes
Simple axis tick label and tick directions
Colors in the default property cycle
Create a colormap from a list of colors
Selecting individual colors from a colormap
Ways to set a color's alpha value
Figure/Axes enter and leave events
Interactive adjustment of colormap range
Colormap normalizations SymLogNorm
Contouring the solution space of optimizations
Blend transparency with color in 2D images
Modifying the coordinate formatter
Contour plot of irregularly spaced data
Layer images with alpha blending
Visualize matrices with matshow
Multiple images with one colorbar
Advanced quiver and quiverkey functions
Bar chart with individual bar colors
Plotting categorical variables
Plotting the coherence of two signals
fill_between with transparency
Fill the area between two vertical lines
Discrete distribution as horizontal bar chart
Dashed line style configuration
Lines with a ticked patheffect
Plotting masked and NaN values
Mapping marker properties to multivariate data
Scatter plot with masked values
Shade regions defined by a logical mask using fill_between
Timeline with lines, dates, and text
Identify whether artists intersect
Add lines directly to a figure
Building histograms using Rectangles and PolyCollections
Clip the data to the axes view limits
Create 2D bar graphs in different planes
Plot contour (level) curves in 3D
Plot contour (level) curves in 3D using the extend3d option
Project contour profiles onto a graph
Project filled contour onto a graph
Custom hillshading in a 3D surface plot
Create 3D histogram of 2D data
3D surface with polar coordinates
Triangular 3D filled contour plot
3D voxel plot of the NumPy logo
3D voxel / volumetric plot with RGB colors
3D voxel / volumetric plot with cylindrical coordinates
3D wireframe plots in one direction
Error bar rendering on polar axis
Text and mathtext using pyplot
Reference for Matplotlib artists
Line, Poly and RegularPoly Collection with autoscaling
Ellipse with orientation arrow demo
Plot multiple lines using a LineCollection
Integral as the area under a curve
Shaded & power normalized rendering
Radar chart (aka spider or star chart)
Long chain of connections using Sankey
SkewT-logP diagram: using transforms and custom projections
Artist customization in box plots
Box plots with custom fill colors
Box plot vs. violin plot comparison
Separate calculation and plotting of boxplots
Plot a confidence ellipse of a two-dimensional dataset
Different ways of specifying error bars
Including upper and lower limits in error bars
Create boxes from error bars using PatchCollection
Demo of the histogram function's different histtype settings
The histogram (hist) function with multiple data sets
Histogram bins, density, and weight
Multiple histograms side by side
Bayesian Methods for Hackers style sheet
Programmatically control subplot adjustment
Controlling view limits using margins and sticky_edges
Draw regions that span an Axes
Resize Axes with constrained layout
Different scales on the same Axes
Figure size in different units
Figure labels: suptitle, supxlabel, supylabel
Combine two subplots using subplots and GridSpec
GridSpec with variable sizes and spacing
Gridspec for multi-column/row subplot layouts
Manage multiple figures in pyplot
Create multiple subplots using plt.subplots
Angle annotations on bracket arrows
The difference between \dfrac and \frac
Format ticks using engineering notation
Annotation arrow style reference
Fonts demo (object-oriented style)
Fonts demo (keyword arguments)
Legend using pre-defined labels
Concatenate text objects with different properties
Render math equations using TeX
Controlling style of text and labels using a dictionary
Text rotation angle in data coordinates
Automatically setting tick positions
Format date ticks using ConciseDateFormatter
Placing date ticks using recurrence rules
Custom tick formatter for time series
SI prefixed offsets and natural order of magnitudes
Set default y-axis tick labels on the right
Setting tick labels from a list of values
Move x-axis tick labels to the top
mplcvd -- an example of figure hook
Select indices from a collection using polygon selector
Image scaling using a RangeSlider
Rectangle and ellipse selectors
Snap sliders to discrete values
fill_between(x1, y1, z1, x2, y2, z2)
Faster rendering by using blitting
Arranging multiple Axes in a Figure
Creating Colormaps in Matplotlib
Choosing Colormaps in Matplotlib
Customizing Matplotlib with style sheets and rcParams