Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Use Axes.tick_params/Axis.set_tick_params more #8678

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 4 commits into from
Aug 13, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use (set_)tick_params more in examples.
  • Loading branch information
QuLogic committed Aug 8, 2017
commit 641ab732cc81b50117ae77bd589f4d482dfce65e
12 changes: 4 additions & 8 deletions 12 examples/api/logos2.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,10 @@ def add_polar_bar():
bar.set_facecolor(cm.jet(r/10.))
bar.set_alpha(0.6)

for label in ax.get_xticklabels() + ax.get_yticklabels():
label.set_visible(False)

for line in ax.get_ygridlines() + ax.get_xgridlines():
line.set_lw(0.8)
line.set_alpha(0.9)
line.set_ls('-')
line.set_color('0.5')
ax.tick_params(labelbottom=False, labeltop=False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had no idea this was possible...cool!

labelleft=False, labelright=False)

ax.grid(lw=0.8, alpha=0.9, ls='-', color='0.5')

ax.set_yticks(np.arange(1, 9, 2))
ax.set_rmax(9)
Expand Down
7 changes: 2 additions & 5 deletions 7 examples/axes_grid1/demo_axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ def demo_locatable_axes_easy(ax):

plt.colorbar(im, cax=ax_cb)
ax_cb.yaxis.tick_right()
for tl in ax_cb.get_yticklabels():
tl.set_visible(False)
ax_cb.yaxis.tick_right()
ax_cb.yaxis.set_tick_params(labelright=False)


def demo_images_side_by_side(ax):
Expand All @@ -94,8 +92,7 @@ def demo_images_side_by_side(ax):

ax.imshow(Z, extent=extent, interpolation="nearest")
ax2.imshow(Z, extent=extent, interpolation="nearest")
for tl in ax2.get_yticklabels():
tl.set_visible(False)
ax2.yaxis.set_tick_params(labelleft=False)


def demo():
Expand Down
10 changes: 2 additions & 8 deletions 10 examples/axes_grid1/scatter_hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
axHisty = divider.append_axes("right", 1.2, pad=0.1, sharey=axScatter)

# make some labels invisible
plt.setp(axHistx.get_xticklabels() + axHisty.get_yticklabels(),
visible=False)
axHistx.xaxis.set_tick_params(labelbottom=False)
axHisty.yaxis.set_tick_params(labelleft=False)

# now determine nice limits by hand:
binwidth = 0.25
Expand All @@ -47,14 +47,8 @@
# thus there is no need to manually adjust the xlim and ylim of these
# axis.

#axHistx.axis["bottom"].major_ticklabels.set_visible(False)
for tl in axHistx.get_xticklabels():
tl.set_visible(False)
axHistx.set_yticks([0, 50, 100])

#axHisty.axis["left"].major_ticklabels.set_visible(False)
for tl in axHisty.get_yticklabels():
tl.set_visible(False)
axHisty.set_xticks([0, 50, 100])

plt.draw()
Expand Down
3 changes: 1 addition & 2 deletions 3 examples/axes_grid1/simple_axes_divider2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
ax[3].set_axes_locator(divider.new_locator(nx=2, nx1=4, ny=0))

for ax1 in ax:
plt.setp(ax1.get_xticklabels()+ax1.get_yticklabels(),
visible=False)
ax1.tick_params(labelbottom=False, labelleft=False)

plt.show()
3 changes: 1 addition & 2 deletions 3 examples/axes_grid1/simple_axes_divider3.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
divider.set_aspect(1.)

for ax1 in ax:
plt.setp(ax1.get_xticklabels()+ax1.get_yticklabels(),
visible=False)
ax1.tick_params(labelbottom=False, labelleft=False)

plt.show()
5 changes: 1 addition & 4 deletions 5 examples/misc/patheffect_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@
PathEffects.Stroke(linewidth=5, foreground="w"),
PathEffects.Normal()])

ax1.grid(True, linestyle="-")

pe = [PathEffects.withStroke(linewidth=3,
foreground="w")]
for l in ax1.get_xgridlines() + ax1.get_ygridlines():
l.set_path_effects(pe)
ax1.grid(True, linestyle="-", path_effects=pe)

ax2 = plt.subplot(132)
arr = np.arange(25).reshape((5, 5))
Expand Down
3 changes: 1 addition & 2 deletions 3 examples/misc/pythonic_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@
ax1.set_ylabel('1 Hz')
ax1.set_title('A sine wave or two')

for label in ax1.get_xticklabels():
label.set_color('r')
ax1.xaxis.set_tick_params(labelcolor='r')


ax2 = fig.add_subplot(212)
Expand Down
17 changes: 3 additions & 14 deletions 17 examples/subplots_axes_and_figures/axes_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,11 @@

t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2 * np.pi * t)

fig, ax = plt.subplots()
ax.plot(t, s)
ax.grid(True)

ticklines = ax.get_xticklines() + ax.get_yticklines()
gridlines = ax.get_xgridlines() + ax.get_ygridlines()
ticklabels = ax.get_xticklabels() + ax.get_yticklabels()

for line in ticklines:
line.set_linewidth(3)

for line in gridlines:
line.set_linestyle('-.')

for label in ticklabels:
label.set_color('r')
label.set_fontsize('medium')
ax.grid(True, linestyle='-.')
ax.tick_params(labelcolor='r', labelsize='medium', width=3)

plt.show()
4 changes: 1 addition & 3 deletions 4 examples/ticks_and_spines/centered_ticklabels.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
associates a label with a tick, and the label can be aligned
'center', 'left', or 'right' using the horizontal alignment property::


for label in ax.xaxis.get_xticklabels():
label.set_horizontalalignment('right')
ax.xaxis.set_tick_params(horizontalalignment='right')

but this doesn't help center the label between ticks. One solution
is to "fake it". Use the minor ticks to place a tick centered
Expand Down
3 changes: 1 addition & 2 deletions 3 examples/ticks_and_spines/date_demo_rrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
plt.plot_date(dates, s)
ax.xaxis.set_major_locator(loc)
ax.xaxis.set_major_formatter(formatter)
labels = ax.get_xticklabels()
plt.setp(labels, rotation=30, fontsize=10)
ax.xaxis.set_tick_params(rotation=30, labelsize=10)

plt.show()
3 changes: 1 addition & 2 deletions 3 examples/userdemo/demo_gridspec01.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
def make_ticklabels_invisible(fig):
for i, ax in enumerate(fig.axes):
ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center")
for tl in ax.get_xticklabels() + ax.get_yticklabels():
tl.set_visible(False)
ax.tick_params(labelbottom=False, labelleft=False)


fig = plt.figure(0)
Expand Down
3 changes: 1 addition & 2 deletions 3 examples/userdemo/demo_gridspec02.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
def make_ticklabels_invisible(fig):
for i, ax in enumerate(fig.axes):
ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center")
for tl in ax.get_xticklabels() + ax.get_yticklabels():
tl.set_visible(False)
ax.tick_params(labelbottom=False, labelleft=False)


fig = plt.figure()
Expand Down
3 changes: 1 addition & 2 deletions 3 examples/userdemo/demo_gridspec03.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
def make_ticklabels_invisible(fig):
for i, ax in enumerate(fig.axes):
ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center")
for tl in ax.get_xticklabels() + ax.get_yticklabels():
tl.set_visible(False)
ax.tick_params(labelbottom=False, labelleft=False)


# demo 3 : gridspec with subplotpars set.
Expand Down
3 changes: 1 addition & 2 deletions 3 examples/userdemo/demo_gridspec04.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
def make_ticklabels_invisible(fig):
for i, ax in enumerate(fig.axes):
ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center")
for tl in ax.get_xticklabels() + ax.get_yticklabels():
tl.set_visible(False)
ax.tick_params(labelbottom=False, labelleft=False)


# gridspec inside gridspec
Expand Down
3 changes: 1 addition & 2 deletions 3 examples/userdemo/demo_gridspec05.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
def make_ticklabels_invisible(fig):
for i, ax in enumerate(fig.axes):
ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center")
for tl in ax.get_xticklabels() + ax.get_yticklabels():
tl.set_visible(False)
ax.tick_params(labelbottom=False, labelleft=False)


f = plt.figure()
Expand Down
8 changes: 3 additions & 5 deletions 8 tools/make_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ def make_matplotlib_icon():
for r, bar in zip(radii, bars):
bar.set_facecolor(cm.jet(r/10.))

for label in ax.get_xticklabels() + ax.get_yticklabels():
label.set_visible(False)

for line in ax.get_ygridlines() + ax.get_xgridlines():
line.set_lw(0.0)
ax.tick_params(labelleft=False, labelright=False,
labelbottom=False, labeltop=False)
ax.grid(lw=0.0)

ax.set_yticks(np.arange(1, 9, 2))
ax.set_rmax(9)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.