Skip to content
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

ticks based on number of subplots #776

Closed

Conversation

ivanov
Copy link
Member

@ivanov ivanov commented Mar 20, 2012

here's an implementation of adjusting the tick locator depending on how many subplots there are. I implemented this at PyData a few weeks back, but forgot to submit the PR.

to see the goodies of this PR, use this in the ipython notebook

%pylab inline
#rcParams['figure.figsize']=2,2
plt.subplots()
plt.plot(24*np.random.rand(10), np.random.rand(10))
for x in range(7):
    fig, axes = plt.subplots(1,x+2, sharey=True)
    for ax in axes.flat: ax.plot(24*np.random.rand(10), np.random.rand(10))

plt.subplots()
plt.plot(np.random.rand(10), 24*np.random.rand(10))

for x in range(7):
    fig, axes = plt.subplots(x+2,1, sharex=True)
    for ax in axes.flat: ax.plot(np.random.rand(10), 24*np.random.rand(10))
#fig.tight_layout()

(I'll rebase this if this won't merge cleanly)

# scale # of ticks to be based on size how many rows we have
nbins = max(2, 7 - int(nrows))
#nbins = max(2, int(10/ nrows))
print(nbins, "y")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like you left a print in here

@jdh2358
Copy link
Collaborator

jdh2358 commented Mar 20, 2012

Hey Paul,

This is a very useful PR, because the too many ticks problem is a common annoyance. I think "subplots" is the perfect place to add enhancements like these because a) it knows the whole geometry and b) it is still somewhat lightly used and so less likely to change/break people's existing code.

I would like to do more: in particular, I think we should expose a tight_layout=True kwarg to subplots so that tight layout is on by default (but configurable), Can you add this to the PR?

We don't need to adjust every locator when either x- or y-axis is shared
across all of the subplots.
@ivanov
Copy link
Member Author

ivanov commented Mar 21, 2012

Hi John,

I removed the print statements, and adjusted the logic for sharex and sharey, since locators get reused in that case.

as for tight_layout, I think with the current implementation, it only make sense to call tight_layout after whatever plotting will happen, since it's a one-time action which only takes into account the current state of the relevant artists. I hope @leejjoon or anyone else corrects me if I'm wrong.

@leejjoon
Copy link
Contributor

Yes, tight_layout is a one-time action. Although we may implement some automatic use, see #774.

@jdh2358
Copy link
Collaborator

jdh2358 commented Mar 25, 2012

Hey Paul,

just wanted to point out that we are in the thick handling the v1.1.x release right now so are in a holding pattern on master PRs, but I am definitely interested in this so make sure to ping us if we fall quite on this PR after we get 1.1.1 out.

JDH

@ivanov ivanov mentioned this pull request Mar 27, 2012
@pelson
Copy link
Member

pelson commented Nov 3, 2012

@ivanov : I think we can start looking at this again now that (for the most part) v1.2.0 is out of the way. Would you be willing to rebase this, and add appropriate tests and we can get this PR back on the agenda.

Cheers,

@ivanov ivanov closed this Dec 8, 2012
@pelson
Copy link
Member

pelson commented Dec 10, 2012

@ivanov is that a no, or a "I'm on it"? 😄

@ivanov
Copy link
Member Author

ivanov commented Dec 11, 2012

both :)

I took a stab and there were too many conflicts immediately, and I didn't
have the mental bandwidth to juggle them at the time, let me take another
stab...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants