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

Skip to content

Increase consistency in tutorials and examples #24004

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
Sep 25, 2022
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
4 changes: 2 additions & 2 deletions examples/color/color_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
# 3) gray level string:
ax.set_title('Voltage vs. time chart', color='0.7')
# 4) single letter color string
ax.set_xlabel('time (s)', color='c')
ax.set_xlabel('Time [s]', color='c')
# 5) a named color:
ax.set_ylabel('voltage (mV)', color='peachpuff')
ax.set_ylabel('Voltage [mV]', color='peachpuff')
# 6) a named xkcd color:
ax.plot(t, s, 'xkcd:crimson')
# 7) Cn notation:
Expand Down
2 changes: 1 addition & 1 deletion examples/color/custom_cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

If, as in this example, there are no discontinuities in the r, g, and b
components, then it is quite simple: the second and third element of
each tuple, above, is the same--call it "``y``". The first element ("``x``")
each tuple, above, is the same -- call it "``y``". The first element ("``x``")
defines interpolation intervals over the full range of 0 to 1, and it
must span that whole range. In other words, the values of ``x`` divide the
0-to-1 range into a set of segments, and ``y`` gives the end-point color
Expand Down
6 changes: 3 additions & 3 deletions examples/lines_bars_and_markers/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
nse1 = np.random.randn(len(t)) # white noise 1
nse2 = np.random.randn(len(t)) # white noise 2

# Two signals with a coherent part at 10Hz and a random part
# Two signals with a coherent part at 10 Hz and a random part
s1 = np.sin(2 * np.pi * 10 * t) + nse1
s2 = np.sin(2 * np.pi * 10 * t) + nse2

fig, axs = plt.subplots(2, 1)
axs[0].plot(t, s1, t, s2)
axs[0].set_xlim(0, 2)
axs[0].set_xlabel('time')
axs[0].set_xlabel('Time')
axs[0].set_ylabel('s1 and s2')
axs[0].grid(True)

cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt)
axs[1].set_ylabel('coherence')
axs[1].set_ylabel('Coherence')

fig.tight_layout()
plt.show()
2 changes: 1 addition & 1 deletion examples/lines_bars_and_markers/csd_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

ax1.plot(t, s1, t, s2)
ax1.set_xlim(0, 5)
ax1.set_xlabel('time')
ax1.set_xlabel('Time')
ax1.set_ylabel('s1 and s2')
ax1.grid(True)

Expand Down
6 changes: 3 additions & 3 deletions examples/pyplots/fig_axes_labels_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
fig = plt.figure()
fig.subplots_adjust(top=0.8)
ax1 = fig.add_subplot(211)
ax1.set_ylabel('volts')
ax1.set_title('a sine wave')
ax1.set_ylabel('Voltage [V]')
ax1.set_title('A sine wave')

t = np.arange(0.0, 1.0, 0.01)
s = np.sin(2 * np.pi * t)
Expand All @@ -23,7 +23,7 @@

ax2 = fig.add_axes([0.15, 0.1, 0.7, 0.3])
n, bins, patches = ax2.hist(np.random.randn(1000), 50)
ax2.set_xlabel('time (s)')
ax2.set_xlabel('Time [s]')

plt.show()

Expand Down
4 changes: 2 additions & 2 deletions examples/pyplots/pyplot_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
plt.text(1, -0.6, r'$\sum_{i=0}^\infty x_i$', fontsize=20)
plt.text(0.6, 0.6, r'$\mathcal{A}\mathrm{sin}(2 \omega t)$',
fontsize=20)
plt.xlabel('time (s)')
plt.ylabel('volts (mV)')
plt.xlabel('Time [s]')
plt.ylabel('Voltage [mV]')
plt.show()

#############################################################################
Expand Down
16 changes: 8 additions & 8 deletions tutorials/advanced/path_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@
# ==============
#
# Some of the path components require multiple vertices to specify them:
# for example CURVE 3 is a `bézier
# for example CURVE 3 is a `Bézier
# <https://en.wikipedia.org/wiki/B%C3%A9zier_curve>`_ curve with one
# control point and one end point, and CURVE4 has three vertices for the
# two control points and the end point. The example below shows a
# CURVE4 Bézier spline -- the bézier curve will be contained in the
# CURVE4 Bézier spline -- the Bézier curve will be contained in the
# convex hull of the start point, the two control points, and the end
# point

Expand Down Expand Up @@ -139,8 +139,8 @@
# for each histogram bar: the rectangle width is the bin width and the
# rectangle height is the number of datapoints in that bin. First we'll
# create some random normally distributed data and compute the
# histogram. Because numpy returns the bin edges and not centers, the
# length of ``bins`` is 1 greater than the length of ``n`` in the
# histogram. Because NumPy returns the bin edges and not centers, the
# length of ``bins`` is one greater than the length of ``n`` in the
# example below::
#
# # histogram our data with numpy
Expand All @@ -159,10 +159,10 @@
#
# Now we have to construct our compound path, which will consist of a
# series of ``MOVETO``, ``LINETO`` and ``CLOSEPOLY`` for each rectangle.
# For each rectangle, we need 5 vertices: 1 for the ``MOVETO``, 3 for
# the ``LINETO``, and 1 for the ``CLOSEPOLY``. As indicated in the
# table above, the vertex for the closepoly is ignored but we still need
# it to keep the codes aligned with the vertices::
# For each rectangle, we need five vertices: one for the ``MOVETO``,
# three for the ``LINETO``, and one for the ``CLOSEPOLY``. As indicated
# in the table above, the vertex for the closepoly is ignored but we still
# need it to keep the codes aligned with the vertices::
#
# nverts = nrects*(1+3+1)
# verts = np.zeros((nverts, 2))
Expand Down
6 changes: 3 additions & 3 deletions tutorials/intermediate/artists.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ class in the Matplotlib API, and the one you will be working with most
fig = plt.figure()
fig.subplots_adjust(top=0.8)
ax1 = fig.add_subplot(211)
ax1.set_ylabel('volts')
ax1.set_title('a sine wave')
ax1.set_ylabel('Voltage [V]')
ax1.set_title('A sine wave')

t = np.arange(0.0, 1.0, 0.01)
s = np.sin(2*np.pi*t)
Expand All @@ -136,7 +136,7 @@ class in the Matplotlib API, and the one you will be working with most
ax2 = fig.add_axes([0.15, 0.1, 0.7, 0.3])
n, bins, patches = ax2.hist(np.random.randn(1000), 50,
facecolor='yellow', edgecolor='yellow')
ax2.set_xlabel('time (s)')
ax2.set_xlabel('Time [s]')

plt.show()

Expand Down
2 changes: 1 addition & 1 deletion tutorials/intermediate/constrainedlayout_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def example_plot(ax, fontsize=12, hide_labels=False):

##########################################
# If there are more than two columns, the *wspace* is shared between them,
# so here the wspace is divided in 2, with a *wspace* of 0.1 between each
# so here the wspace is divided in two, with a *wspace* of 0.1 between each
# column:

fig, axs = plt.subplots(2, 3, layout="constrained")
Expand Down
6 changes: 4 additions & 2 deletions tutorials/introductory/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,10 @@ def f(t):
# plt.figure(2) # a second figure
# plt.plot([4, 5, 6]) # creates a subplot() by default
#
# plt.figure(1) # figure 1 current; subplot(212) still current
# plt.subplot(211) # make subplot(211) in figure1 current
# plt.figure(1) # first figure current;
# # subplot(212) still current
# plt.subplot(211) # make subplot(211) in the first figure
# # current
# plt.title('Easy as 1, 2, 3') # subplot 211 title
#
# You can clear the current figure with `~.pyplot.clf`
Expand Down
12 changes: 6 additions & 6 deletions tutorials/text/text_intro.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
fig, ax = plt.subplots(figsize=(5, 3))
fig.subplots_adjust(bottom=0.15, left=0.2)
ax.plot(x1, y1)
ax.set_xlabel('time [s]')
ax.set_xlabel('Time [s]')
ax.set_ylabel('Damped oscillation [V]')

plt.show()
Expand All @@ -131,7 +131,7 @@
fig, ax = plt.subplots(figsize=(5, 3))
fig.subplots_adjust(bottom=0.15, left=0.2)
ax.plot(x1, y1*10000)
ax.set_xlabel('time [s]')
ax.set_xlabel('Time [s]')
ax.set_ylabel('Damped oscillation [V]')

plt.show()
Expand All @@ -144,7 +144,7 @@
fig, ax = plt.subplots(figsize=(5, 3))
fig.subplots_adjust(bottom=0.15, left=0.2)
ax.plot(x1, y1*10000)
ax.set_xlabel('time [s]')
ax.set_xlabel('Time [s]')
ax.set_ylabel('Damped oscillation [V]', labelpad=18)

plt.show()
Expand All @@ -159,7 +159,7 @@
fig, ax = plt.subplots(figsize=(5, 3))
fig.subplots_adjust(bottom=0.15, left=0.2)
ax.plot(x1, y1)
ax.set_xlabel('time [s]', position=(0., 1e6), horizontalalignment='left')
ax.set_xlabel('Time [s]', position=(0., 1e6), horizontalalignment='left')
ax.set_ylabel('Damped oscillation [V]')

plt.show()
Expand All @@ -179,7 +179,7 @@
fig, ax = plt.subplots(figsize=(5, 3))
fig.subplots_adjust(bottom=0.15, left=0.2)
ax.plot(x1, y1)
ax.set_xlabel('time [s]', fontsize='large', fontweight='bold')
ax.set_xlabel('Time [s]', fontsize='large', fontweight='bold')
ax.set_ylabel('Damped oscillation [V]', fontproperties=font)

plt.show()
Expand All @@ -191,7 +191,7 @@
fig, ax = plt.subplots(figsize=(5, 3))
fig.subplots_adjust(bottom=0.2, left=0.2)
ax.plot(x1, np.cumsum(y1**2))
ax.set_xlabel('time [s] \n This was a long experiment')
ax.set_xlabel('Time [s] \n This was a long experiment')
ax.set_ylabel(r'$\int\ Y^2\ dt\ \ [V^2 s]$')
plt.show()

Expand Down