Skip to content

Set sharex/sharey to False if using 3d plots - #7047

Merged
Illviljan merged 1 commit into
pydata:mainfrom
Illviljan:facetgrid_default_sharex_sharey_if_3d_plot
Sep 25, 2022
Merged

Set sharex/sharey to False if using 3d plots#7047
Illviljan merged 1 commit into
pydata:mainfrom
Illviljan:facetgrid_default_sharex_sharey_if_3d_plot

Conversation

@Illviljan

@IllviljanIllviljan commented Sep 16, 2022

Copy link
Copy Markdown
Contributor

Matplotlibs 3d plots appears to not support sharex/sharey. So reset to default values instead. This improves the look of the plot as axis values aren't deleted.

Example:

importmatplotlib.pyplotaspltfig=plt.figure()
subplot_kws= {"projection":"3d"}
ax1=fig.add_subplot(211, **subplot_kws)
ax1.plot([0, 1, 2], [5,6,6])
ax2=fig.add_subplot(212, sharex=ax1, **subplot_kws)
ax2.plot([0, 1, 2], [5,4,2]) # x axis is not linked.

Split up from #6778.

@mathause

Copy link
Copy Markdown
Collaborator

Does this warrant a test? But good to go anyways.

@Illviljan

Copy link
Copy Markdown
ContributorAuthor

I'm not sure how to check that sharex works or not. Any ideas?

@mathause

Copy link
Copy Markdown
Collaborator

Maybe:

len(list(ax.get_shared_x_axes())) !=0

@IllviljanIllviljan mentioned this pull request Sep 25, 2022
3 tasks
@Illviljan

Copy link
Copy Markdown
ContributorAuthor

I'll add the test in a future pr.

@Illviljan
Illviljan merged commit 212a5d7 into pydata:mainSep 25, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Illviljan@mathause