Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Hide "inner" {x,y}labels in label_outer too.#6619

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tacaswell merged 2 commits intomatplotlib:masterfromanntzer:labelouter-hide-labels
Jul 12, 2016

Conversation

anntzer
Copy link
Contributor

ax.label_outer used to hide only "inner" ticklabels; make it hide axes
labels too. (I couldn't find a way to just switch label visibility, so
I just set the labels to the empty string instead.)

`ax.label_outer` used to hide only "inner" ticklabels; make it hide axeslabels too.  (I couldn't find a way to just switch label visibility, soI just set the labels to the empty string instead.)
@tacaswelltacaswell added this to the2.1 (next point release) milestoneJun 21, 2016
@afvincent
Copy link
Contributor

@anntzer I didn't find an example ofax.label_outer in the example gallery so wouldn't your PR be the occasion to add one? For example something like:

"""When plotting a grid of subplots that share axes, it might be interestingto display only some of the tick labels as well as some of the axes labels.The `label_outer` method provides a convenient way of dealing with thisby setting visible only the x tick and axis labels of the bottom row andthe y tick and axis labels of the left column."""importmatplotlib.pyplotaspltimportnumpyasnp# Dummy data to plott=np.linspace(0.0,5.0,501)s1=1.25*np.sin(2*np.pi*t)s2=np.exp(-t)s3=np.sin(4*np.pi*t)s4=np.sin(2*np.pi*t)*np.exp(-t)# Instantiate a 2x2 subplot grid with both shared x and y axes.fig,axs=plt.subplots(ncols=2,nrows=2,sharex=True,sharey=True)# Plot a data signal in each subplot and display:# - y tick and axis labels only for the first column;# - x tick and axis labels only for the last row.forax,s,titlein ((axs[0,0],s1,'Left labels ON'),                     (axs[0,1],s2,'All labels OFF'),                     (axs[1,0],s3,'Left & bottom labels ON'),                     (axs[1,1],s4,'Bottom labels ON')):ax.plot(t,s)ax.set_xlabel('This is x-axis')ax.set_ylabel('This is y-axis')ax.label_outer()# Display only the "relevant" tick & axis labels.ax.set_title(title)plt.show()

if one wants to add a simple stand-alone example. And if one doesn't like such a small stand-alone example, then the examplesubplots_demo may be a good place to add the same kind of example.

For the moment (without the current PR), the provided snippet results in
example_label_outer
but this should improve with what you proposed.

@anntzer
Copy link
ContributorAuthor

I updatedsubplots_demo instead.

@afvincent
Copy link
Contributor

Nice! In fact, I hadn't directly proposed to modify the existing example in the case someone thought it would be useful to keep an example of the “cosmetricks” like

plt.setp([a.get_xticklabels()forainaxarr[0, :]],visible=False)plt.setp([a.get_yticklabels()forainaxarr[:,1]],visible=False)

which might give more fine-tuning possibilities if one doesn't simply want to label only the “outer” subplots. However if one had to choose, aslabel_outer will now also handle “inner” axis labels (as well as it also takes care of the possible offset texts), which the former “cosmetrick” doesn't, I really thinklabel_outer should be demonstrated over the former technic.

@anntzer
Copy link
ContributorAuthor

Actually the previous approach is "broken" in the sense that it will not handle offset texts (see#4445,#4446), so I'd rather just not have it in the examples here.

@afvincent
Copy link
Contributor

If I wasn't clear in my previous comment: I agree with you aboutlabel_outer being a better solution than the former approach because it takes care of the offset texts (as well as of the x- and y-labels with this PR).

@tacaswelltacaswell merged commit4786a0b intomatplotlib:masterJul 12, 2016
@anntzeranntzer deleted the labelouter-hide-labels branchDecember 1, 2016 23:13
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v2.1
Development

Successfully merging this pull request may close these issues.

4 participants
@anntzer@afvincent@mdboom@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp