Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pgf backend. Y-labels in subplot are not alligned after baseline but bottom of letter #1321

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

Closed
jenshnielsen opened this issue Sep 30, 2012 · 4 comments

Comments

@jenshnielsen
Copy link
Member

In the following example the baseline of the y labels are not aligned, rather it seems like the bottom of the g in one is aligned to the baseline of the other label. (The xlabels seems right) Using the pdf backend it appears correct. The issue does not seem to depend on the xelatex vs pdflatex and different fonts.

@pwuertz is this related to #1115 ?

import matplotlib
matplotlib.use('pgf')
import matplotlib.pyplot as plt
import numpy as np

params = {
          'text.usetex': True,
          'pgf.texsystem': 'xelatex',
          }
plt.rcParams.update(params)

fig,ax = plt.subplots(2,2)

ax[0,0].set_ylabel('test',fontsize=30) #large font size to make it easier to see
ax[1,0].set_ylabel('testg',fontsize=30)
ax[1,0].set_xlabel('test',fontsize=30)
ax[1,1].set_xlabel('testg',fontsize=30)
fig.savefig('test.pdf')
@pwuertz
Copy link
Contributor

pwuertz commented Sep 30, 2012

It's not "yet" related to #1115. What I would like to do is to pass the position and alignment information to the backend and handle text layout there.

At the moment, the positioning is fully determined by matplotlib and I do not see any difference using the PDF backend in your example. Using matplotlib's standard pdf output, I also see non-baseline aligned y-labels.

This is not really a surprise, since matplotlib aligns text elements by the bounding box of the global coordinate system. The Y-Label is therefore aligned with its right edge, not with a baseline. Baseline alignment is not possible for rotated texts using this scheme. So the question is... why do you see baseline aligned y-labels on your system ^^ ?

@pwuertz
Copy link
Contributor

pwuertz commented Sep 30, 2012

Oh, and the x-labels are not aligned to their base either. Their top line is aligned, which is the same for "test" and "testg". Also, in the usual case you don't really want baseline alignment. If your text (a formula maybe) exceeds the base or the top, you don't want it to overlap the ticks or the graph.

I guess the only way to handle co-baseline-aligned labels like the ones in the example is to do implement it in gridspec. One has to iterate over all subplots, check the sizes of the text elements and determine a common baseline.

@pwuertz
Copy link
Contributor

pwuertz commented Sep 30, 2012

Might be important to remember such a use-case for the re-design of matplotlibs layout technique #1109

@jenshnielsen
Copy link
Member Author

I was sure that it worked with the pdf backend but cant seem to reproduce it now. Sorry for the noise.

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

No branches or pull requests

2 participants