Skip to content

Commit

Permalink
Close all plot windows of a blocking show() on Ctrl+C
Browse files Browse the repository at this point in the history
Addresses the Qt part of matplotlib#23385.

It appears that `qapp.quit()` does not automatically close the windows
of the app. We therefore do it explicitly.

A unit test for this would be quite complex. Test this
by hand by Ctrl+C in an interactive shell.
  • Loading branch information
timhoffm committed Oct 11, 2023
1 parent 6501209 commit ac7f86b
Show file tree
Hide file tree
Showing 63 changed files with 122 additions and 102 deletions.
13 changes: 13 additions & 0 deletions doc/_templates/autosummary_class_only_noindex.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{ fullname | escape | underline }}


.. currentmodule:: {{ module }}


{% if objtype in ['class'] %}

.. auto{{ objtype }}:: {{ objname }}
:no-members:
:no-index:
{% endif %}
7 changes: 6 additions & 1 deletion doc/api/figure_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@

The Figure class
================
.. class:: Figure

Creation
--------

.. autosummary::
:toctree: _as_gen
:template: autosummary_class_only.rst
:template: autosummary_class_only_noindex.rst
:nosignatures:

Figure
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/animation/multiple_axes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
=======================
Multiple axes animation
Multiple Axes animation
=======================
This example showcases:
Expand Down
4 changes: 2 additions & 2 deletions galleries/examples/axes_grid1/demo_axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Axes divider
============
Axes divider to calculate location of axes and
create a divider for them using existing axes instances.
Axes divider to calculate location of Axes and
create a divider for them using existing Axes instances.
"""

import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/axes_grid1/demo_axes_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Demo Axes Grid
==============
Grid of 2x2 images with a single colorbar or with one colorbar per axes.
Grid of 2x2 images with a single colorbar or with one colorbar per Axes.
"""

import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/axes_grid1/demo_axes_hbox_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Using an `.HBoxDivider` to arrange subplots.
Note that both axes' location are adjusted so that they have
Note that both Axes' location are adjusted so that they have
equal heights while maintaining their aspect ratios.
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
===============================
Adding a colorbar to inset axes
Adding a colorbar to inset Axes
===============================
"""

Expand Down
12 changes: 6 additions & 6 deletions galleries/examples/axes_grid1/demo_colorbar_with_axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
Colorbar with AxesDivider
=========================
The `.axes_divider.make_axes_locatable` function takes an existing axes, adds
The `.axes_divider.make_axes_locatable` function takes an existing Axes, adds
it to a new `.AxesDivider` and returns the `.AxesDivider`. The `.append_axes`
method of the `.AxesDivider` can then be used to create a new axes on a given
side ("top", "right", "bottom", or "left") of the original axes. This example
uses `.append_axes` to add colorbars next to axes.
method of the `.AxesDivider` can then be used to create a new Axes on a given
side ("top", "right", "bottom", or "left") of the original Axes. This example
uses `.append_axes` to add colorbars next to Axes.
Users should consider simply passing the main axes to the *ax* keyword argument of
`~.Figure.colorbar` instead of creating a locatable axes manually like this.
Users should consider simply passing the main Axes to the *ax* keyword argument of
`~.Figure.colorbar` instead of creating a locatable Axes manually like this.
See :ref:`colorbar_placement`.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
This example shows how to control the position, height, and width of colorbars
using `~mpl_toolkits.axes_grid1.inset_locator.inset_axes`.
Inset axes placement is controlled as for legends: either by providing a *loc*
Inset Axes placement is controlled as for legends: either by providing a *loc*
option ("upper right", "best", ...), or by providing a locator with respect to
the parent bbox. Parameters such as *bbox_to_anchor* and *borderpad* likewise
work in the same way, and are also demonstrated here.
Expand Down
6 changes: 3 additions & 3 deletions galleries/examples/axes_grid1/scatter_hist_locatable_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
Show the marginal distributions of a scatter plot as histograms at the sides of
the plot.
For a nice alignment of the main axes with the marginals, the axes positions
For a nice alignment of the main Axes with the marginals, the Axes positions
are defined by a ``Divider``, produced via `.make_axes_locatable`. Note that
the ``Divider`` API allows setting axes sizes and pads in inches, which is its
the ``Divider`` API allows setting Axes sizes and pads in inches, which is its
main feature.
If one wants to set axes sizes and pads relative to the main Figure, see the
If one wants to set Axes sizes and pads relative to the main Figure, see the
:doc:`/gallery/lines_bars_and_markers/scatter_hist` example.
"""

Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/axisartist/demo_curvelinear_grid2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
This example demonstrates how to use GridHelperCurveLinear to define
custom grids and ticklines by applying a transformation on the grid.
As showcase on the plot, a 5x5 matrix is displayed on the axes.
As showcase on the plot, a 5x5 matrix is displayed on the Axes.
"""

import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/axisartist/demo_parasite_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Parasite Axes demo
==================
Create a parasite axes. Such axes would share the x scale with a host axes,
Create a parasite Axes. Such Axes would share the x scale with a host Axes,
but show a different scale in y direction.
This approach uses `mpl_toolkits.axes_grid1.parasite_axes.HostAxes` and
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/color/colorbar_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Use `~.Figure.colorbar` by specifying the mappable object (here
the `.AxesImage` returned by `~.axes.Axes.imshow`)
and the axes to attach the colorbar to.
and the Axes to attach the colorbar to.
"""

import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/event_handling/data_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class PointBrowser:
"""
Click on a point to select and highlight it -- the data that
generated the point will be shown in the lower axes. Use the 'n'
generated the point will be shown in the lower Axes. Use the 'n'
and 'p' keys to browse through the next and previous points
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def heatmap(data, row_labels, col_labels, ax=None,
A list or array of length N with the labels for the columns.
ax
A `matplotlib.axes.Axes` instance to which the heatmap is plotted. If
not provided, use current axes or create a new one. Optional.
not provided, use current Axes or create a new one. Optional.
cbar_kw
A dictionary with arguments to `matplotlib.Figure.colorbar`. Optional.
cbarlabel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
====================
Plot two curves, then use `.EventCollection`\s to mark the locations of the x
and y data points on the respective axes for each curve.
and y data points on the respective Axes for each curve.
"""

import matplotlib.pyplot as plt
Expand Down
4 changes: 2 additions & 2 deletions galleries/examples/lines_bars_and_markers/filled_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def filled_hist(ax, edges, values, bottoms=None, orientation='v',
Parameters
----------
ax : Axes
The axes to plot to
The Axes to plot to.
edges : array
A length n+1 array giving the left edges of each bin and the
Expand Down Expand Up @@ -85,7 +85,7 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
Parameters
----------
ax : axes.Axes
The axes to add artists too
The Axes to add artists to.
stacked_data : array or Mapping
A (M, N) shaped array. The first dimension will be iterated over to
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/lines_bars_and_markers/gradient_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def gradient_image(ax, direction=0.3, cmap_range=(0, 1), **kwargs):
Parameters
----------
ax : Axes
The axes to draw on.
The Axes to draw on.
direction : float
The direction of the gradient. This is a number in
range 0 (=vertical) to 1 (=horizontal).
Expand Down
10 changes: 5 additions & 5 deletions galleries/examples/lines_bars_and_markers/scatter_hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
Show the marginal distributions of a scatter plot as histograms at the sides of
the plot.
For a nice alignment of the main axes with the marginals, two options are shown
For a nice alignment of the main Axes with the marginals, two options are shown
below:
.. contents::
:local:
While `.Axes.inset_axes` may be a bit more complex, it allows correct handling
of main axes with a fixed aspect ratio.
of main Axes with a fixed aspect ratio.
An alternative method to produce a similar figure using the ``axes_grid1``
toolkit is shown in the :doc:`/gallery/axes_grid1/scatter_hist_locatable_axes`
example. Finally, it is also possible to position all axes in absolute
example. Finally, it is also possible to position all Axes in absolute
coordinates using `.Figure.add_axes` (not shown here).
Let us first define a function that takes x and y data as input, as well
as three axes, the main axes for the scatter, and two marginal axes. It will
then create the scatter and histograms inside the provided axes.
as three Axes, the main Axes for the scatter, and two marginal Axes. It will
then create the scatter and histograms inside the provided Axes.
"""

import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/misc/coords_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Coords Report
=============
Override the default reporting of coords as the mouse moves over the axes
Override the default reporting of coords as the mouse moves over the Axes
in an interactive backend.
"""

Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/misc/fig_x.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Adding lines to figures
=======================
Adding lines to a figure without any axes.
Adding lines to a figure without any Axes.
.. redirect-from:: /gallery/pyplots/fig_x
"""
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/misc/logos2.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_font_properties():

def create_icon_axes(fig, ax_position, lw_bars, lw_grid, lw_border, rgrid):
"""
Create a polar axes containing the matplotlib radar plot.
Create a polar Axes containing the matplotlib radar plot.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/misc/rasterization_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Whether rasterization should be used can be specified per artist. This can be
useful to reduce the file size of large artists, while maintaining the
advantages of vector graphics for other artists such as the axes
advantages of vector graphics for other artists such as the Axes
and text. For instance a complicated `~.Axes.pcolormesh` or
`~.Axes.contourf` can be made significantly simpler by rasterizing.
Setting rasterization only affects vector backends such as PDF, SVG, or PS.
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/mplot3d/mixed_subplots.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
=============================
2D and 3D axes in same figure
2D and 3D Axes in same figure
=============================
This example shows a how to plot a 2D and a 3D plot on the same figure.
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/mplot3d/pathpatch3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

def text3d(ax, xyz, s, zdir="z", size=None, angle=0, usetex=False, **kwargs):
"""
Plots the string *s* on the axes *ax*, with position *xyz*, size *size*,
Plots the string *s* on the Axes *ax*, with position *xyz*, size *size*,
and rotation angle *angle*. *zdir* gives the axis which is to be treated as
the third dimension. *usetex* is a boolean indicating whether the string
should be run through a LaTeX subprocess or not. Any additional keyword
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/pie_and_polar_charts/bar_of_pie.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Make a "bar of pie" chart where the first slice of the pie is
"exploded" into a bar chart with a further breakdown of said slice's
characteristics. The example demonstrates using a figure with multiple
sets of axes and using the axes patches list to add two ConnectionPatches
sets of Axes and using the axes patches list to add two ConnectionPatches
to link the subplot charts.
"""

Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/pyplots/pyplot_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Set the special text objects `~.pyplot.title`, `~.pyplot.xlabel`, and
`~.pyplot.ylabel` through the dedicated pyplot functions. Additional text
objects can be placed in the axes using `~.pyplot.text`.
objects can be placed in the Axes using `~.pyplot.text`.
You can use TeX-like mathematical typesetting in all texts; see also
:ref:`mathtext`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
This example demonstrates how to use `.collections.PatchCollection`.
See also :doc:`/gallery/shapes_and_collections/artist_reference`, which instead
adds each artist separately to its own axes.
adds each artist separately to its own Axes.
"""

import matplotlib.pyplot as plt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def bullseye_plot(ax, data, seg_bold=None, cmap="viridis", norm=None):
Parameters
----------
ax : axes
ax : Axes
data : list[float]
The intensity values for each of the 17 segments.
seg_bold : list[int], optional
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/specialty_plots/radar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def radar_factory(num_vars, frame='circle'):
num_vars : int
Number of variables for radar chart.
frame : {'circle', 'polygon'}
Shape of frame surrounding axes.
Shape of frame surrounding Axes.
"""
# calculate evenly-spaced axis angles
Expand Down
4 changes: 2 additions & 2 deletions galleries/examples/spines/multiple_yaxis_with_spines.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
===========================
Create multiple y axes with a shared x-axis. This is done by creating
a `~.axes.Axes.twinx` axes, turning all spines but the right one invisible
a `~.axes.Axes.twinx` Axes, turning all spines but the right one invisible
and offset its position using `~.spines.Spine.set_position`.
Note that this approach uses `matplotlib.axes.Axes` and their
`~matplotlib.spines.Spine`\s. Alternative approaches using non-standard axes
`~matplotlib.spines.Spine`\s. Alternative approaches using non-standard Axes
are shown in the :doc:`/gallery/axisartist/demo_parasite_axes` and
:doc:`/gallery/axisartist/demo_parasite_axes2` examples.
"""
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/spines/spines_dropped.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Dropped spines
==============
Demo of spines offset from the axes (a.k.a. "dropped spines").
Demo of spines offset from the Axes (a.k.a. "dropped spines").
"""
import matplotlib.pyplot as plt
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/statistics/boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
individual components (note that the mean is the only value not shown by
default). The second figure demonstrates how the styles of the artists can be
customized. It also demonstrates how to set the limit of the whiskers to
specific percentiles (lower right axes)
specific percentiles (lower right Axes)
A good general reference on boxplots and their history can be found here:
https://vita.had.co.nz/papers/boxplots.pdf
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/statistics/confidence_ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def confidence_ellipse(x, y, ax, n_std=3.0, facecolor='none', **kwargs):
Input data.
ax : matplotlib.axes.Axes
The axes object to draw the ellipse into.
The Axes object to draw the ellipse into.
n_std : float
The number of standard deviations to determine the ellipse's radiuses.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
===============
This demo shows how to set the aspect of an Axes box directly via
`~.Axes.set_box_aspect`. The box aspect is the ratio between axes height
`~.Axes.set_box_aspect`. The box aspect is the ratio between Axes height
and axes width in physical units, independent of the data limits.
This is useful to e.g. produce a square plot, independent of the data it
contains, or to have a usual plot with the same axes dimensions next to
Expand Down
2 changes: 1 addition & 1 deletion galleries/examples/subplots_axes_and_figures/axes_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Axes Demo
=========
Example use of ``fig.add_axes`` to create inset axes within the main plot axes.
Example use of ``fig.add_axes`` to create inset Axes within the main plot Axes.
Please see also the :ref:`axes_grid_examples` section, and the following three
examples:
Expand Down
Loading

0 comments on commit ac7f86b

Please sign in to comment.