Skip to content

Use tick_params more often over tick iteration #23377

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
Jul 1, 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
5 changes: 1 addition & 4 deletions examples/axes_grid1/demo_axes_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,8 @@ def demo_rgb2():
ax_b.imshow(im_b)

for ax in fig.axes:
ax.tick_params(axis='both', direction='in')
ax.tick_params(direction='in', color='w')
ax.spines[:].set_color("w")
for tick in ax.xaxis.get_major_ticks() + ax.yaxis.get_major_ticks():
tick.tick1line.set_markeredgecolor("w")
tick.tick2line.set_markeredgecolor("w")


demo_rgb1()
Expand Down
3 changes: 1 addition & 2 deletions examples/images_contours_and_fields/image_masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
ax1.set_title('Green=low, Red=high, Blue=masked')
cbar = fig.colorbar(im, extend='both', shrink=0.9, ax=ax1)
cbar.set_label('uniform')
for ticklabel in ax1.xaxis.get_ticklabels():
ticklabel.set_visible(False)
ax1.tick_params(axis='x', labelbottom=False)

# Plot using a small number of colors, with unevenly spaced boundaries.
im = ax2.imshow(Zm, interpolation='nearest',
Expand Down
3 changes: 1 addition & 2 deletions examples/lines_bars_and_markers/fill_between_alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@

for ax in ax1, ax2:
ax.grid(True)
ax.label_outer()

ax1.set_ylabel('price')
for label in ax2.get_yticklabels():
label.set_visible(False)

fig.suptitle('Google (GOOG) daily closing price')
fig.autofmt_xdate()
Expand Down
14 changes: 2 additions & 12 deletions examples/pyplots/fig_axes_customize_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,8 @@
rect = ax1.patch
rect.set_facecolor('lightslategray')


for label in ax1.xaxis.get_ticklabels():
# label is a Text instance
label.set_color('tab:red')
label.set_rotation(45)
label.set_fontsize(16)

for line in ax1.yaxis.get_ticklines():
# line is a Line2D instance
line.set_markeredgecolor('tab:green')
line.set_markersize(25)
line.set_markeredgewidth(3)
ax1.tick_params(axis='x', labelcolor='tab:red', labelrotation=45, labelsize=16)
ax1.tick_params(axis='y', color='tab:green', size=25, width=3)

plt.show()

Expand Down
3 changes: 1 addition & 2 deletions examples/subplots_axes_and_figures/align_labels_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
ax.set_ylabel('YLabel1 %d' % i)
ax.set_xlabel('XLabel1 %d' % i)
if i == 0:
for tick in ax.get_xticklabels():
tick.set_rotation(55)
ax.tick_params(axis='x', rotation=55)
fig.align_labels() # same as fig.align_xlabels(); fig.align_ylabels()

plt.show()