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

Skip to content

Commit 771cb80

Browse files
deep-jkljklymak
authored and
Jakub Klus
committed
Apply all suggestions from code review
Will be revised. Co-authored-by: Jody Klymak <[email protected]>
1 parent d464483 commit 771cb80

File tree

1 file changed

+13
-32
lines changed

1 file changed

+13
-32
lines changed

tutorials/intermediate/autoscale.py

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,12 @@
22
Autoscaling
33
===========
44
5-
Axis scales define the overall look of a plot, some default options
6-
scale ranges automatically with respect to supplied data - autoscaling.
7-
This tutorial shows concepts of individual autoscaling options and
8-
investigates cornerstone examples regarding the needs for manual adjustments.
9-
The limits on an axis can be set manually (e.g. ``ax.set_xlim(xmin, xmax)``)
10-
or Matplotlib can set them automatically based on the data already on the
11-
axes. There are a number of options to this autoscaling behaviour,
12-
discussed below.
5+
The limits on an axis can be set manually (e.g. ``ax.set_xlim(xmin, xmax)``) or Matplotlib can set them automatically based on the data already on the axes. There are a number of options to this autoscaling behaviour, discussed below.
136
"""
147

158
###############################################################################
169
# We will start with a simple line plot showing that autoscaling
17-
# extends the visible range 5% beyond the real data range (-2π, 2π).
10+
# extends the axis limits 5% beyond the data limits (-2π, 2π).
1811

1912
import numpy as np
2013
import matplotlib as mpl
@@ -30,23 +23,21 @@
3023
###############################################################################
3124
# Margins
3225
# -------
33-
# The relative measure of the extend is called margin and can be set by
34-
# `~matplotlib.axes.Axes.margins`.
35-
# The default value is (0.05, 0.05):
26+
# The default margin around the data limits is 5%:
3627

3728
ax.margins()
3829

3930
###############################################################################
40-
# The margins can be made larger:
31+
# The margins can be made larger using `~matplotlib.axes.Axes.margins`:
4132

4233
fig, ax = plt.subplots()
4334
ax.plot(x, y)
4435
ax.margins(0.2, 0.2)
4536
fig.show()
4637

4738
###############################################################################
48-
# In general, margins shall be in range (-0.5, ∞), negative margins crop the
49-
# plot showing only a part of the data. Using a single number for margins
39+
# In general, margins can be in the range (-0.5, ∞), where negative margins set the axes limits to
40+
# a fraction of the data range, and allow a zoom effect. Using a single number for margins
5041
# affects both axes, a single margin can be customized using keyword
5142
# arguments ``x`` or ``y``, but positional and keyword interface cannot be
5243
# combined
@@ -57,18 +48,11 @@
5748
fig.show()
5849

5950
###############################################################################
60-
# There is the last keyword argument for margins call, the ``tight`` option. In
61-
# the case of a simple :func:`~matplotlib.axes.Axes.plot` call, this parameter
62-
# does not change anything, it is passed to the
63-
# :meth:`~matplotlib.axes.Axes.autoscale_view`, which requires more advanced
64-
# discussion.
6551
#
66-
# Margins can behave differently for certain plots, this is determined by
67-
# the sticky edges property, which is of interest in the next section.
6852
#
6953
# Sticky edges
7054
# ------------
71-
# Margin must not be applied for certain :class:`.Artist`, for example, setting
55+
# Some :class:`.Artist` objects do not allow margins. For example, setting
7256
# ``margin=0.2`` on ``plt.imshow`` does not affect the resulting plot.
7357
#
7458

@@ -84,16 +68,13 @@
8468
fig.show()
8569

8670
###############################################################################
87-
# This override of margins is determined by so-called sticky edges. That is a
88-
# property of :class:`.Artist` class, which can suppress adding margins to data
89-
# limits. The effect of sticky edges can be disabled by changing
90-
# :class:`~matplotlib.axes.Axes` property
91-
# `~matplotlib.axes.Axes.use_sticky_edges`.
92-
#
93-
# Settings of sticky edges of individual artists can be investigating by
94-
# accessing them directly, `.Artist.sticky_edges`. Moreover, the values of
71+
# This override of margins is determined by "sticky edges", a
72+
# property of :class:`.Artist` class that can suppress adding margins to axis
73+
# limits. The effect of sticky edges can be disabled on an Axes by changing
74+
# `~matplotlib.axes.Axes.use_sticky_edges`.
75+
# Artists have a property `.Artist.sticky_edges`, and the values of
9576
# sticky edges can be changed by writing to ``Artist.sticky_edges.x`` or
96-
# ``.Artist.sticky_edges.y``
77+
# ``.Artist.sticky_edges.y``.
9778
#
9879
# The following example shows how overriding works and when it is needed.
9980

0 commit comments

Comments
 (0)