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

Plot title should be shifted up when xticks are set to the top of the plot #1415

Closed
ppurka opened this issue Oct 19, 2012 · 9 comments
Closed

Comments

@ppurka
Copy link

ppurka commented Oct 19, 2012

This is an issue that came up in http://trac.sagemath.org/13625

When subplot.xaxis.tick_top() is used, then the position of the plot title is not recomputed. Ideally, it should be shifted further up. Example code is as follows

from matplotlib.figure import Figure
figure = Figure()
subplot = figure.add_subplot(111)
subplot.plot(range(10),range(10))
subplot.xaxis.tick_top()
subplot.set_title('a title')
from matplotlib.backends.backend_agg import FigureCanvasAgg
figure.set_canvas(FigureCanvasAgg(figure))
figure.savefig('/tmp/a.png')
@pelson
Copy link
Member

pelson commented Oct 19, 2012

Definitely another one for the #1109 folio.

The traditional fix which seems to have been used in axes.spy and axes.matshow is to set the y position of the title to axes.get_title.set_y(1.05), but there are obvious pitfalls with this approach...

@kcrisman
Copy link
Contributor

Looking at #1109, does that mean this is not going to be fixed soon, or does it mean this is fixable now but #1109 would provide a more elegant overall solution? We may try a workaround on the Sage end, but if there is a patch we could apply to mpl, that would be even better.

@ppurka
Copy link
Author

ppurka commented Oct 19, 2012

I see the mention of QML in #1109. The ideas in QML seem quite similar to the ones in edje, which is one of the libraries behind enlightenment and has been around for nearly a decade ( see http://www.enlightenment.org and http://docs.enlightenment.org/auto/edje/ ). So, it might be useful for you to look at that project since all the theming and layout in enlightenment happens through edje.

@pelson
Copy link
Member

pelson commented Oct 19, 2012

but there are obvious pitfalls with this approach...

I have just trawled the axes.py module and looking at it, anything which extends beyond the plotting area is done in this way (axes coordinates outside of the range 0 <= x <=1), so while this approach obviously has pitfalls, it is also consistent with how the title and tickmarks are already being done...

@pelson
Copy link
Member

pelson commented Oct 19, 2012

Looking at #1109, does that mean this is not going to be fixed soon

No, it is not even clear how what is going to be implemented at this point, we are still very much at the brainstorming stage.

@ppurka : please feel free to put your suggestions in the geom manager issue - what you are saying sounds very sensible indeed.

Cheers,

Khodeir pushed a commit to Khodeir/matplotlib that referenced this issue Mar 25, 2014
…graph title when xticks are set to the top of the plot by swapping graph title position to bellow of the x-axis.
Khodeir pushed a commit to Khodeir/matplotlib that referenced this issue Mar 25, 2014
…le when xticks are set to the top of the plot by swapping graph title position to bellow of the x-axis for when user sets the title first and then tick_top.
Khodeir pushed a commit to Khodeir/matplotlib that referenced this issue Mar 27, 2014
…graph title when xticks are set to the top of the plot by swapping graph title position to bellow of the x-axis.
Khodeir pushed a commit to Khodeir/matplotlib that referenced this issue Mar 27, 2014
…le when xticks are set to the top of the plot by swapping graph title position to bellow of the x-axis for when user sets the title first and then tick_top.
@petehuang
Copy link
Contributor

I reproduced with 1.5.3:

temp

Recommend labeling as geometry manager to mirror #1109, which is still the source of truth for this work

@efiring
Copy link
Member

efiring commented Jan 3, 2017

I think that if there is going to be a partial fix for this any time soon, it will be via using the same logic for the titles as we are using for the xlabel and ylabel. They are already taking into account the ticks and tick labels. An additional wrinkle might be the case of twinned axes; the title-positioning logic for either axes would have to check for ticks and tick labels on both axes.

@efiring efiring added the topic: geometry manager LayoutEngine, Constrained layout, Tight layout label Jan 3, 2017
@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Oct 3, 2017
@jklymak jklymak modified the milestones: needs sorting, v3.0 Mar 8, 2018
@jklymak
Copy link
Member

jklymak commented Mar 8, 2018

This is fixed by #9498. Removing geometry manager label, as its not necessary for this...

@jklymak jklymak removed the topic: geometry manager LayoutEngine, Constrained layout, Tight layout label Mar 8, 2018
@afvincent
Copy link
Contributor

Closed by #9498 (commit 7b30275).

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

No branches or pull requests

8 participants