Thanks to visit codestin.com
Credit goes to github.com

Skip to content

dynamically generate pyplot functions #9173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ Matplotlib requires a large number of dependencies:
* `six <https://pypi.python.org/pypi/six>`_
* `backports.functools_lru_cache <https://pypi.python.org/pypi/backports.functools_lru_cache>`_
(for Python 2.7 only)
* `funcsigs <https://pypi.python.org/pypi/funcsigs>`_ (for Python 2.7 only)
* `subprocess32 <https://pypi.python.org/pypi/subprocess32/>`_ (for Python
2.7 only, on Linux and macOS only)

Expand Down Expand Up @@ -324,7 +325,7 @@ without fiddling with environment variables::
# this package is only available in the conda-forge channel
conda install -c conda-forge msinttypes
# for Python 2.7
conda install -c conda-forge backports.functools_lru_cache
conda install -c conda-forge backports.functools_lru_cache funcsigs

# copy the libs which have "wrong" names
set LIBRARY_LIB=%CONDA_DEFAULT_ENV%\Library\lib
Expand Down
2 changes: 1 addition & 1 deletion build_alllocal.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:: # this package is only available in the conda-forge channel
:: conda install -c conda-forge msinttypes
:: if you build on py2.7:
:: conda install -c conda-forge backports.functools_lru_cache
:: conda install -c conda-forge backports.functools_lru_cache funcsigs

set TARGET=bdist_wheel
IF [%1]==[] (
Expand Down
16 changes: 8 additions & 8 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1394,25 +1394,25 @@ def get_backend():

def interactive(b):
"""
Set interactive mode to boolean b.
Set interactive mode to boolean *b*.

If b is True, then draw after every plotting command, e.g., after xlabel
If *b* is True, then draw after every plotting command, e.g., after xlabel.
"""
rcParams['interactive'] = b


def is_interactive():
'Return true if plot mode is interactive'
"""Return whether interactive mode is on."""
return rcParams['interactive']


def tk_window_focus():
"""Return true if focus maintenance under TkAgg on win32 is on.
This currently works only for python.exe and IPython.exe.
Both IDLE and Pythonwin.exe fail badly when tk_window_focus is on."""
if rcParams['backend'] != 'TkAgg':
return False
return rcParams['tk.window_focus']

This currently works only for python.exe and IPython.exe.
Both IDLE and Pythonwin.exe fail badly when tk_window_focus is on.
"""
return rcParams['backend'] == 'TkAgg' and rcParams['tk.window_focus']


default_test_modules = [
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def get_ylabel(self):

def set_ylabel(self, ylabel, fontdict=None, labelpad=None, **kwargs):
"""
Set the label for the yaxis
Set the label for the yaxis.

Parameters
----------
Expand Down
88 changes: 41 additions & 47 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1606,45 +1606,40 @@ def apply_aspect(self, position=None):
self.set_xbound((x0, x1))

def axis(self, *v, **kwargs):
"""Set axis properties.
"""Convenience method to get or set axis properties.

Valid signatures::

xmin, xmax, ymin, ymax = axis()
xmin, xmax, ymin, ymax = axis(list_arg)
xmin, xmax, ymin, ymax = axis(string_arg)
xmin, xmax, ymin, ymax = axis(**kwargs)
xmin, xmax, ymin, ymax = axis(*, emit=True)
xmin, xmax, ymin, ymax = axis(_string_arg_, *, emit=True)
xmin, xmax, ymin, ymax = axis([xmin, ymin, xmax, ymax], *, emit=True)

Parameters
----------
v : list of float or {'on', 'off', 'equal', 'tight', 'scaled',\
'normal', 'auto', 'image', 'square'}
Optional positional argument

Axis data limits set from a list; or a command relating to axes:

========== ================================================
Value Description
========== ================================================
'on' Toggle axis lines and labels on
'off' Toggle axis lines and labels off
'equal' Equal scaling by changing limits
'scaled' Equal scaling by changing box dimensions
'tight' Limits set such that all data is shown
'auto' Automatic scaling, fill rectangle with data
'normal' Same as 'auto'; deprecated
'image' 'scaled' with axis limits equal to data limits
'square' Square plot; similar to 'scaled', but initially\
forcing xmax-xmin = ymax-ymin
========== ================================================

emit : bool, optional
Passed to set_{x,y}lim functions, if observers
are notified of axis limit change
_string_arg_ : str, optional

The following values are allowed:

========== =======================================================
Value Description
========== =======================================================
'on' Toggle axis lines and labels on
'off' Toggle axis lines and labels off
'equal' Equal scaling by changing limits
'scaled' Equal scaling by changing box dimensions
'tight' Limits set such that all data is shown
'auto' Automatic scaling, fill rectangle with data
'image' 'scaled' with axis limits equal to data limits
'square' Square plot; similar to 'scaled', but initially forcing
``xmax-xmin = ymax-ymin``
========== =======================================================

xmin, ymin, xmax, ymax : float, optional
The axis limits to be set

emit : bool, optional
Whether observers are notified of axes limit changes.

Returns
-------
xmin, xmax, ymin, ymax : float
Expand All @@ -1665,17 +1660,15 @@ def axis(self, *v, **kwargs):
self.set_axis_on()
elif s == 'off':
self.set_axis_off()
elif s in ('equal', 'tight', 'scaled', 'normal',
'auto', 'image', 'square'):
elif s in ['equal', 'tight', 'scaled', 'auto', 'image', 'square']:
self.set_autoscale_on(True)
self.set_aspect('auto')
self.autoscale_view(tight=False)
# self.apply_aspect()
if s == 'equal':
self.set_aspect('equal', adjustable='datalim')
elif s == 'scaled':
self.set_aspect('equal', adjustable='box', anchor='C')
self.set_autoscale_on(False) # Req. by Mark Bakker
self.set_autoscale_on(False)
elif s == 'tight':
self.autoscale_view(tight=True)
self.set_autoscale_on(False)
Expand Down Expand Up @@ -1770,18 +1763,19 @@ def get_yticklines(self):
# Adding and tracking artists

def _sci(self, im):
"""
helper for :func:`~matplotlib.pyplot.sci`;
do not use elsewhere.
"""Set the current image.

This image will be the target of colormap functions like
`~matplotlib.pyplot.viridis`, and other functions such as
`~matplotlib.pyplot.hot` or `~matplotlib.pyplot.clim`. The current
image is an attribute of the current axes.
"""
if isinstance(im, matplotlib.contour.ContourSet):
if im.collections[0] not in self.collections:
raise ValueError(
"ContourSet must be in current Axes")
raise ValueError("ContourSet must be in current Axes")
elif im not in self.images and im not in self.collections:
raise ValueError(
"Argument must be an image, collection, or ContourSet in "
"this Axes")
raise ValueError("Argument must be an image, collection, or "
"ContourSet in this Axes")
self._current_image = im

def _gci(self):
Expand Down Expand Up @@ -3102,14 +3096,14 @@ def set_xscale(self, value, **kwargs):
"""
Set the x-axis scale.

..
ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ]

Parameters
----------
value : {"linear", "log", "symlog", "logit"}
scaling strategy to apply

..
ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ]

Notes
-----
Different kwargs are accepted, depending on the scale. See
Expand Down Expand Up @@ -3427,14 +3421,14 @@ def set_yscale(self, value, **kwargs):
"""
Set the y-axis scale.

..
ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ]

Parameters
----------
value : {"linear", "log", "symlog", "logit"}
scaling strategy to apply

..
ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ]

Notes
-----
Different kwargs are accepted, depending on the scale. See
Expand Down
60 changes: 33 additions & 27 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,7 @@ def _set_artist_props(self, a):
@docstring.dedent_interpd
def gca(self, **kwargs):
"""
Get the current axes, creating one if necessary
Get the current axes, creating one if necessary.

The following kwargs are supported for ensuring the returned axes
adheres to the given projection etc., and for axes creation if
Expand Down Expand Up @@ -1675,17 +1675,14 @@ def gca(self, **kwargs):
return self.add_subplot(1, 1, 1, **kwargs)

def sca(self, a):
'Set the current axes to be a and return a'
"""Set the current axes to be a and return a."""
self._axstack.bubble(a)
for func in self._axobservers:
func(self)
return a

def _gci(self):
"""
helper for :func:`~matplotlib.pyplot.gci`;
do not use elsewhere.
"""
"""Get the current colorable artist."""
# Look first for an image in the current Axes:
cax = self._axstack.current_key_axes()[1]
if cax is None:
Expand Down Expand Up @@ -1921,18 +1918,30 @@ def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw):
self.stale = True
return cb

def subplots_adjust(self, *args, **kwargs):
def subplots_adjust(self, left=None, bottom=None, right=None, top=None,
wspace=None, hspace=None):
"""
Call signature::
Update the figure's `SubplotParams` and the subplot locations.

subplots_adjust(left=None, bottom=None, right=None, top=None,
wspace=None, hspace=None)
All parameters default to their respective rcParams.

Update the :class:`SubplotParams` with *kwargs* (defaulting to rc when
*None*) and update the subplot locations

"""
self.subplotpars.update(*args, **kwargs)
Parameters
----------
left : float
Left edge of the subplots of the figure.
right : float
Right edge of the subplots of the figure.
bottom : float
Bottom edge of the subplots of the figure.
top : float
Top edge of the subplots of the figure.
wspace : float
Amount of width reserved as blank space between subplots.
hspace : float
Amount of height reserved as blank space between subplots.
"""
self.subplotpars.update(left=left, bottom=bottom, right=right, top=top,
wspace=wspace, hspace=hspace)
for ax in self.axes:
if not isinstance(ax, SubplotBase):
# Check if sharing a subplots axis
Expand Down Expand Up @@ -2053,19 +2062,16 @@ def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,

Parameters
----------

pad : float
padding between the figure edge and the edges of subplots,
as a fraction of the font-size.

pad : float, optional
Padding between the figure edge and the edges of subplots, as a
fraction of the font-size.
h_pad, w_pad : float, optional
padding (height/width) between edges of adjacent subplots.
Defaults to `pad_inches`.

rect : tuple (left, bottom, right, top), optional
a rectangle (left, bottom, right, top) in the normalized
figure coordinate that the whole subplots area (including
labels) will fit into. Default is (0, 0, 1, 1).
Padding (height/width) between edges of adjacent subplots.
Defaults to *pad_inches*.
rect : Tuple[float, float, float, float], optional
(left, bottom, right, top) rectangle in normalized figure
coordinates that the whole subplots area (including labels) will
fit into. Defaults to using the entire figure.
"""

from .tight_layout import (
Expand Down
Loading