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

Skip to content

Backport PR #10278 on branch v2.2.x #10807

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

Merged
merged 1 commit into from
Mar 16, 2018
Merged
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
144 changes: 78 additions & 66 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ def plot(self, *args, **kwargs):
Returns
-------
lines
A list of `.Line2D` objects that were added.
A list of `.Line2D` objects representing the plotted data.


See Also
Expand Down Expand Up @@ -1565,7 +1565,7 @@ def plot_date(self, x, y, fmt='o', tz=None, xdate=True, ydate=False,
Returns
-------
lines
A list of `.Line2D` objects that were added to the axes.
A list of `~.Line2D` objects representing the plotted data.


Other Parameters
Expand Down Expand Up @@ -1614,36 +1614,45 @@ def plot_date(self, x, y, fmt='o', tz=None, xdate=True, ydate=False,
@docstring.dedent_interpd
def loglog(self, *args, **kwargs):
"""
Make a plot with log scaling on both the *x* and *y* axis.
Make a plot with log scaling on both the x and y axis.

Call signatures::

:func:`~matplotlib.pyplot.loglog` supports all the keyword
arguments of :func:`~matplotlib.pyplot.plot` and
:meth:`matplotlib.axes.Axes.set_xscale` /
:meth:`matplotlib.axes.Axes.set_yscale`.
loglog([x], y, [fmt], data=None, **kwargs)
loglog([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)

This is just a thin wrapper around `.plot` which additionally changes
both the x-axis and the y-axis to log scaling. All of the concepts and
parameters of plot can be used here as well.

The additional parameters *basex/y*, *subsx/y* and *nonposx/y* control
the x/y-axis properties. They are just forwarded to `.Axes.set_xscale`
and `.Axes.set_yscale`.

Parameters
----------
basex, basey : scalar
Base of the x/y logarithm. Must be > 1.
basex, basey : scalar, optional, default 10
Base of the x/y logarithm.

subsx, subsy : sequence
The location of the minor x/y ticks; ``None`` defaults to autosubs,
which depend on the number of decades in the plot;
see :meth:`matplotlib.axes.Axes.set_xscale` /
:meth:`matplotlib.axes.Axes.set_yscale` for details.
subsx, subsy : sequence, optional
The location of the minor x/y ticks. If *None*, reasonable
locations are automatically chosen depending on the number of
decades in the plot.
See `.Axes.set_xscale` / `.Axes.set_yscale` for details.

nonposx, nonposy : ['mask' | 'clip' ]
nonposx, nonposy : {'mask', 'clip'}, optional, default 'mask'
Non-positive values in x or y can be masked as invalid, or clipped
to a very small positive number.

Returns
-------
lines
A list of `~.Line2D` objects representing the plotted data.

Other Parameters
----------------
**kwargs :
The remaining valid kwargs are :class:`~matplotlib.lines.Line2D`
properties:

%(Line2D)s

**kwargs
All parameters supported by `.plot`.
"""
if not self._hold:
self.cla()
Expand All @@ -1669,39 +1678,41 @@ def semilogx(self, *args, **kwargs):
"""
Make a plot with log scaling on the x axis.

Call signatures::

semilogx([x], y, [fmt], data=None, **kwargs)
semilogx([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)

This is just a thin wrapper around `.plot` which additionally changes
the x-axis to log scaling. All of the concepts and parameters of plot
can be used here as well.

The additional parameters *basex*, *subsx* and *nonposx* control the
x-axis properties. They are just forwarded to `.Axes.set_xscale`.

Parameters
----------
basex : float, optional
Base of the x logarithm. The scalar should be larger than 1.
basex : scalar, optional, default 10
Base of the x logarithm.

subsx : array_like, optional
The location of the minor xticks; ``None`` defaults to
autosubs, which depend on the number of decades in the
plot; see :meth:`~matplotlib.axes.Axes.set_xscale` for
details.
The location of the minor xticks. If *None*, reasonable locations
are automatically chosen depending on the number of decades in the
plot. See `.Axes.set_xscale` for details.

nonposx : string, optional, {'mask', 'clip'}
Non-positive values in x can be masked as
invalid, or clipped to a very small positive number.
nonposx : {'mask', 'clip'}, optional, default 'mask'
Non-positive values in x can be masked as invalid, or clipped to a
very small positive number.

Returns
-------
`~matplotlib.pyplot.plot`
Log-scaled plot on the x axis.
lines
A list of `~.Line2D` objects representing the plotted data.

Other Parameters
----------------
**kwargs :
Keyword arguments control the :class:`~matplotlib.lines.Line2D`
properties:

%(Line2D)s

Notes
-----
This function supports all the keyword arguments of
:func:`~matplotlib.pyplot.plot` and
:meth:`matplotlib.axes.Axes.set_xscale`.
**kwargs
All parameters supported by `.plot`.
"""
if not self._hold:
self.cla()
Expand All @@ -1721,41 +1732,42 @@ def semilogy(self, *args, **kwargs):
"""
Make a plot with log scaling on the y axis.

Call signatures::

semilogy([x], y, [fmt], data=None, **kwargs)
semilogy([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)

This is just a thin wrapper around `.plot` which additionally changes
the y-axis to log scaling. All of the concepts and parameters of plot
can be used here as well.

The additional parameters *basey*, *subsy* and *nonposy* control the
y-axis properties. They are just forwarded to `.Axes.set_yscale`.

Parameters
----------
basey : float, optional
Base of the y logarithm. The scalar should be larger than 1.
basey : scalar, optional, default 10
Base of the y logarithm.

subsy : array_like, optional
The location of the minor yticks; ``None`` defaults to
autosubs, which depend on the number of decades in the
plot; see :meth:`~matplotlib.axes.Axes.set_yscale` for
details.
The location of the minor yticks. If *None*, reasonable locations
are automatically chosen depending on the number of decades in the
plot. See `.Axes.set_yscale` for details.

nonposy : string, optional, {'mask', 'clip'}
Non-positive values in *y* can be masked as
invalid, or clipped to a very small positive number.
nonposy : {'mask', 'clip'}, optional, default 'mask'
Non-positive values in y can be masked as invalid, or clipped to a
very small positive number.

Returns
-------
`~matplotlib.pyplot.plot`
Log-scaled plot on the *y* axis.
lines
A list of `~.Line2D` objects representing the plotted data.

Other Parameters
----------------
**kwargs :
Keyword arguments control the :class:`~matplotlib.lines.Line2D`
properties:

%(Line2D)s

Notes
-----
This function supports all the keyword arguments of
:func:`~matplotlib.pyplot.plot` and
:meth:`matplotlib.axes.Axes.set_yscale`.
**kwargs
All parameters supported by `.plot`.
"""

if not self._hold:
self.cla()
d = {k: kwargs.pop(k) for k in ['basey', 'subsy', 'nonposy']
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ def __init__(self, axis, **kwargs):

if nonpos not in ['mask', 'clip']:
raise ValueError("nonposx, nonposy kwarg must be 'mask' or 'clip'")
if base <= 0 or base == 1:
raise ValueError('The log base cannot be <= 0 or == 1')

if base == 10.0:
self._transform = self.Log10Transform(nonpos)
Expand Down