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

Skip to content

Cleanup examples #20631

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 1 commit 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: 1 addition & 2 deletions examples/animation/animate_decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def data_gen():


def init():
ax.set_ylim(-1.1, 1.1)
ax.set_xlim(0, 10)
ax.set(xlim=(0, 10), ylim=(-1.1, 1.1))
del xdata[:]
del ydata[:]
line.set_data(xdata, ydata)
Expand Down
3 changes: 1 addition & 2 deletions examples/animation/bayes_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def __init__(self, ax, prob=0.5):
self.ax = ax

# Set up plot parameters
self.ax.set_xlim(0, 1)
self.ax.set_ylim(0, 10)
self.ax.set(xlim=(0, 1), ylim=(0, 10))
self.ax.grid(True)

# This vertical line represents the theoretical value, to
Expand Down
4 changes: 2 additions & 2 deletions examples/animation/rain.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
# Create new Figure and an Axes which fills it.
fig = plt.figure(figsize=(7, 7))
ax = fig.add_axes([0, 0, 1, 1], frameon=False)
ax.set_xlim(0, 1), ax.set_xticks([])
ax.set_ylim(0, 1), ax.set_yticks([])
ax.set(xticks=[], xlim=(0, 1),
yticks=[], ylim=(0, 1))

# Create rain data
n_drops = 50
Expand Down
3 changes: 1 addition & 2 deletions examples/animation/strip_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def __init__(self, ax, maxt=2, dt=0.02):
self.ydata = [0]
self.line = Line2D(self.tdata, self.ydata)
self.ax.add_line(self.line)
self.ax.set_ylim(-.1, 1.1)
self.ax.set_xlim(0, self.maxt)
self.ax.set(xlim=(0, self.maxt), ylim=(-.1, 1.1))

def update(self, y):
lastt = self.tdata[-1]
Expand Down
3 changes: 1 addition & 2 deletions examples/axisartist/axis_direction.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
def setup_axes(fig, pos):
ax = fig.add_subplot(pos, axes_class=axisartist.Axes)

ax.set_ylim(-0.1, 1.5)
ax.set_yticks([0, 1])
ax.set(ylim=(-0.1, 1.5), yticks=[0, 1])

ax.axis[:].set_visible(False)

Expand Down
9 changes: 3 additions & 6 deletions examples/axisartist/demo_ticklabel_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ def setup_axes(fig, pos):
fig.subplots_adjust(left=0.5, hspace=0.7)

ax = setup_axes(fig, 311)
ax.set_ylabel("ha=right")
ax.set_xlabel("va=baseline")
ax.set(xlabel="va=baseline", ylabel="ha=right")

ax = setup_axes(fig, 312)
ax.axis["left"].major_ticklabels.set_ha("center")
ax.axis["bottom"].major_ticklabels.set_va("top")
ax.set_ylabel("ha=center")
ax.set_xlabel("va=top")
ax.set(xlabel="va=top", ylabel="ha=center")

ax = setup_axes(fig, 313)
ax.axis["left"].major_ticklabels.set_ha("left")
ax.axis["bottom"].major_ticklabels.set_va("bottom")
ax.set_ylabel("ha=left")
ax.set_xlabel("va=bottom")
ax.set(xlabel="va=bottom", ylabel="ha=left")

plt.show()
3 changes: 1 addition & 2 deletions examples/axisartist/demo_ticklabel_direction.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

def setup_axes(fig, pos):
ax = fig.add_subplot(pos, axes_class=axislines.Axes)
ax.set_yticks([0.2, 0.8])
ax.set_xticks([0.2, 0.8])
ax.set(xticks=[0.2, 0.8], yticks=[0.2, 0.8])
return ax


Expand Down
3 changes: 1 addition & 2 deletions examples/axisartist/simple_axis_direction03.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

def setup_axes(fig, pos):
ax = fig.add_subplot(pos, axes_class=axisartist.Axes)
ax.set_yticks([0.2, 0.8])
ax.set_xticks([0.2, 0.8])
ax.set(xticks=[0.2, 0.8], yticks=[0.2, 0.8])
return ax


Expand Down
6 changes: 3 additions & 3 deletions examples/event_handling/poly_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def on_mouse_move(self, event):
ax.add_patch(poly)
p = PolygonInteractor(ax, poly)

ax.set_title('Click and drag a point to move it')
ax.set_xlim((-2, 2))
ax.set_ylim((-2, 2))
ax.set(xlim=(-2, 2), ylim=(-2, 2),
title='Click and drag a point to move it')

plt.show()
3 changes: 1 addition & 2 deletions examples/images_contours_and_fields/affine_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def do_plot(ax, Z, transform):
x1, x2, y1, y2 = im.get_extent()
ax.plot([x1, x2, x2, x1, x1], [y1, y1, y2, y2, y1], "y--",
transform=trans_data)
ax.set_xlim(-5, 5)
ax.set_ylim(-4, 4)
ax.set(xlim=(-5, 5), ylim=(-4, 4))


# prepare image and figure
Expand Down
4 changes: 1 addition & 3 deletions examples/images_contours_and_fields/pcolormesh_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def _annotate(ax, x, y, title):
# this all gets repeated below:
X, Y = np.meshgrid(x, y)
ax.plot(X.flat, Y.flat, 'o', color='m')
ax.set_xlim(-0.7, 5.2)
ax.set_ylim(-0.7, 3.2)
ax.set_title(title)
ax.set(xlim=(-0.7, 5.2), ylim=(-0.7, 3.2), title=title)

_annotate(ax, x, y, "shading='flat'")

Expand Down
5 changes: 1 addition & 4 deletions examples/lines_bars_and_markers/eventcollection_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@
ax.add_collection(yevents2)

# set the limits
ax.set_xlim([0, 1])
ax.set_ylim([0, 1])

ax.set_title('line plot with data points')
ax.set(xlim=[0, 1], ylim=[0, 1], title='line plot with data points')

# display the plot
plt.show()
10 changes: 3 additions & 7 deletions examples/lines_bars_and_markers/markevery_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ def trim_axs(axs, N):
axs = plt.figure(figsize=figsize, constrained_layout=True).subplots(rows, cols)
axs = trim_axs(axs, len(cases))
for ax, case in zip(axs, cases):
ax.set_title('markevery=%s' % str(case))
ax.set_xscale('log')
ax.set_yscale('log')
ax.set(xscale='log', yscale='log', title=f'markevery={case!r}')
ax.plot(x, y, 'o', ls='-', ms=4, markevery=case)

###############################################################################
Expand All @@ -79,10 +77,8 @@ def trim_axs(axs, N):
axs = plt.figure(figsize=figsize, constrained_layout=True).subplots(rows, cols)
axs = trim_axs(axs, len(cases))
for ax, case in zip(axs, cases):
ax.set_title('markevery=%s' % str(case))
ax.plot(x, y, 'o', ls='-', ms=4, markevery=case)
ax.set_xlim((6, 6.7))
ax.set_ylim((1.1, 1.7))
ax.set(xlim=(6, 6.7), ylim=(1.1, 1.7), title=f'markevery={case!r}')

# define data for polar plots
r = np.linspace(0, 3.0, 200)
Expand All @@ -95,7 +91,7 @@ def trim_axs(axs, N):
rows, cols, subplot_kw={'projection': 'polar'})
axs = trim_axs(axs, len(cases))
for ax, case in zip(axs, cases):
ax.set_title('markevery=%s' % str(case))
ax.set_title(f'markevery={case!r}')
ax.plot(theta, r, 'o', ls='-', ms=4, markevery=case)

plt.show()
3 changes: 1 addition & 2 deletions examples/misc/demo_agg_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ def drop_shadow_line(ax):
shadow.set_agg_filter(gauss)
shadow.set_rasterized(True) # to support mixed-mode renderers

ax.set_xlim(0., 1.)
ax.set_ylim(0., 1.)
ax.set(xlim=(0, 1), ylim=(0, 1))

ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
Expand Down
3 changes: 1 addition & 2 deletions examples/misc/demo_ribbon_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ def main():
ax.add_artist(RibbonBoxImage(ax, bbox, bc, interpolation="bicubic"))
ax.annotate(str(h), (year, h), va="bottom", ha="center")

ax.set_xlim(years[0] - 0.5, years[-1] + 0.5)
ax.set_ylim(0, 10000)
ax.set(xlim=(years[0] - 0.5, years[-1] + 0.5), ylim=(0, 10000))

background_gradient = np.zeros((2, 2, 4))
background_gradient[:, :, :3] = [1, 1, 0]
Expand Down
10 changes: 3 additions & 7 deletions examples/mplot3d/contour3d_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@
cset = ax.contour(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
cset = ax.contour(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)

ax.set_xlim(-40, 40)
ax.set_ylim(-40, 40)
ax.set_zlim(-100, 100)

ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set(xlabel='X', xlim=(-40, 40),
ylabel='Y', ylim=(-40, 40),
zlabel='Z', zlim=(-100, 100))

plt.show()
10 changes: 3 additions & 7 deletions examples/mplot3d/contourf3d_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@
cset = ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
cset = ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)

ax.set_xlim(-40, 40)
ax.set_ylim(-40, 40)
ax.set_zlim(-100, 100)

ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set(xlabel='X', xlim=(-40, 40),
ylabel='Y', ylim=(-40, 40),
zlabel='Z', zlim=(-100, 100))

plt.show()
5 changes: 1 addition & 4 deletions examples/pyplots/text_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@

ax = fig.add_subplot()
fig.subplots_adjust(top=0.85)
ax.set_title('axes title')

ax.set_xlabel('xlabel')
ax.set_ylabel('ylabel')
ax.set(xlabel='xlabel', ylabel='ylabel', title='axes title')

ax.text(3, 8, 'boxed italics text in data coords', style='italic',
bbox={'facecolor': 'red', 'alpha': 0.5, 'pad': 10})
Expand Down
3 changes: 1 addition & 2 deletions examples/scales/log_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
ax.set_xticklabels(map(str, x))
ax.set_yscale('log')

ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set(xlabel='x', ylabel='y')

plt.show()
6 changes: 2 additions & 4 deletions examples/shapes_and_collections/line_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@

# We need to set the plot limits.
fig, ax = plt.subplots()
ax.set_xlim(x.min(), x.max())
ax.set_ylim(ys.min(), ys.max())
ax.set(xlim=(x.min(), x.max()), ylim=(ys.min(), ys.max()))

# *colors* is sequence of rgba tuples.
# *linestyle* is a string or dash tuple. Legal string values are
Expand Down Expand Up @@ -62,8 +61,7 @@

# We need to set the plot limits, they will not autoscale
fig, ax = plt.subplots()
ax.set_xlim(np.min(x), np.max(x))
ax.set_ylim(np.min(ys), np.max(ys))
ax.set(xlim=(np.min(x), np.max(x)), ylim=(np.min(ys), np.max(ys)))

# colors is sequence of rgba tuples
# linestyle is a string or dash tuple. Legal string values are
Expand Down
3 changes: 1 addition & 2 deletions examples/showcase/mandelbrot.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def mandelbrot_set(xmin, xmax, ymin, ymax, xn, yn, maxiter, horizon=2.0):
M = light.shade(M, cmap=plt.cm.hot, vert_exag=1.5,
norm=colors.PowerNorm(0.3), blend_mode='hsv')
ax.imshow(M, extent=[xmin, xmax, ymin, ymax], interpolation="bicubic")
ax.set_xticks([])
ax.set_yticks([])
ax.set(xticks=[], yticks=[])

# Some advertisement for matplotlib
year = time.strftime("%Y")
Expand Down
11 changes: 4 additions & 7 deletions examples/showcase/xkcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
ax = fig.add_axes((0.1, 0.2, 0.8, 0.7))
ax.spines.right.set_color('none')
ax.spines.top.set_color('none')
ax.set_xticks([])
ax.set_yticks([])
ax.set_ylim([-30, 10])
ax.set(xticks=[], yticks=[], ylim=[-30, 10])

data = np.ones(100)
data[70:] -= np.arange(30)
Expand All @@ -31,8 +29,7 @@

ax.plot(data)

ax.set_xlabel('time')
ax.set_ylabel('my overall health')
ax.set(xlabel='time', ylabel='my overall health')
fig.text(
0.5, 0.05,
'"Stove Ownership" from xkcd by Randall Munroe',
Expand All @@ -50,8 +47,8 @@
ax.spines.right.set_color('none')
ax.spines.top.set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.set_xticks([0, 1])
ax.set_xticklabels(['CONFIRMED BY\nEXPERIMENT', 'REFUTED BY\nEXPERIMENT'])
ax.set_xticks([0, 1],
['CONFIRMED BY\nEXPERIMENT', 'REFUTED BY\nEXPERIMENT'])
ax.set_xlim([-0.5, 1.5])
ax.set_yticks([])
ax.set_ylim([0, 110])
Expand Down
4 changes: 1 addition & 3 deletions examples/specialty_plots/leftventricle_bulleye.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ def bullseye_plot(ax, data, seg_bold=None, cmap=None, norm=None):
if 17 in seg_bold:
ax.plot(theta0, r0, '-k', lw=linewidth + 2)

ax.set_ylim([0, 1])
ax.set_yticklabels([])
ax.set_xticklabels([])
ax.set(ylim=[0, 1], xticklabels=[], yticklabels=[])


# Create the fake data
Expand Down
3 changes: 1 addition & 2 deletions examples/specialty_plots/skewt.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ def upper_xlim(self):
# Disables the log-formatting that comes with semilogy
ax.yaxis.set_major_formatter(ScalarFormatter())
ax.yaxis.set_minor_formatter(NullFormatter())
ax.set_yticks(np.linspace(100, 1000, 10))
ax.set_ylim(1050, 100)
ax.set(yticks=np.linspace(100, 1000, 10), ylim=(1050, 100))

ax.xaxis.set_major_locator(MultipleLocator(10))
ax.set_xlim(-50, 50)
Expand Down
6 changes: 2 additions & 4 deletions examples/statistics/boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
axs[1, 2].set_title('showfliers=False', fontsize=fs)

for ax in axs.flat:
ax.set_yscale('log')
ax.set_yticklabels([])
ax.set(yscale='log', yticklabels=[])

fig.subplots_adjust(hspace=0.4)
plt.show()
Expand Down Expand Up @@ -88,8 +87,7 @@
axs[1, 2].set_title('whis=[15, 85]\n#percentiles', fontsize=fs)

for ax in axs.flat:
ax.set_yscale('log')
ax.set_yticklabels([])
ax.set(yscale='log', yticklabels=[])

fig.suptitle("I never said they'd be pretty")
fig.subplots_adjust(hspace=0.4)
Expand Down
3 changes: 1 addition & 2 deletions examples/statistics/boxplot_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
# adding horizontal grid lines
for ax in [ax1, ax2]:
ax.yaxis.grid(True)
ax.set_xlabel('Three separate samples')
ax.set_ylabel('Observed values')
ax.set(xlabel='Three separate samples', ylabel='Observed values')

plt.show()

Expand Down
6 changes: 2 additions & 4 deletions examples/statistics/bxp.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
axs[1, 2].set_title('showfliers=False', fontsize=fs)

for ax in axs.flat:
ax.set_yscale('log')
ax.set_yticklabels([])
ax.set(yscale='log', yticklabels=[])

fig.subplots_adjust(hspace=0.4)
plt.show()
Expand Down Expand Up @@ -96,8 +95,7 @@
axs[1, 1].set_title('Custom mean\nas line', fontsize=fs)

for ax in axs.flat:
ax.set_yscale('log')
ax.set_yticklabels([])
ax.set(yscale='log', yticklabels=[])

fig.suptitle("I never said they'd be pretty")
fig.subplots_adjust(hspace=0.4)
Expand Down
3 changes: 1 addition & 2 deletions examples/statistics/multiple_histograms_side_by_side.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
ax.set_xticks(x_locations)
ax.set_xticklabels(labels)

ax.set_ylabel("Data values")
ax.set_xlabel("Data sets")
ax.set(xlabel="Data sets", ylabel="Data values")

plt.show()

Expand Down
Loading