pgf-tikz / pgfplots

pgfplots - A TeX package to draw normal and/or logarithmic plots directly in TeX in two and three dimensions with a user-friendly interface and pgfplotstable - a TeX package to round and format numerical tables. Examples in manuals and/or on web site.
http://pgfplots.sourceforge.net/
198 stars 34 forks source link

Improper base alignment axis legend with old style figures #45

Closed pgf-tikz-bot closed 4 years ago

pgf-tikz-bot commented 12 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/45/ Author: nobody Timestamp: 2012-04-10 09:12:07

When using old-style figures for labelling an axis, the numbers are not properly aligned. This is most easily demonstrated with an example, see the attached screenshot.

Thanks for considering my report. And no, this is no spam such as the five last few posts :-(.

pgf-tikz-bot commented 12 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/45/#47e5 Author: *anonymous Timestamp: 2012-04-10 09:12:10

https://sourceforge.net/p/pgfplots/bugs/_discuss/thread/e6c01f1e/47e5/attachment/Selection_040.png Notice the alignment of 2006

pgf-tikz-bot commented 12 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/45/#6a8d Author: ludewich Timestamp: 2012-07-28 21:36:27

pgf-tikz-bot commented 12 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/45/#7569 Author: ludewich Timestamp: 2012-07-28 21:36:27

Thanks for the bug report!

It is funny, sometimes I receive email notifications and sometimes not. Why did I not receive this one!? Seems I should not rely on sourceforge email notifications. Sorry for the late response.

Anyway: I noted the problem.

In the meantime, there are some ways to overcome this weakness:

\documentclass[a4paper]{article}

\usepackage{pgfplots}

\pgfplotsset{compat=1.5}

\begin{document}

% 1. If you provided your tick labels explicitlcy: add \strut to the text:

\begin{tikzpicture} \begin{axis}[xtick={1,2},xticklabels={\strut g,\strut G}] \addplot {x}; \end{axis} \end{tikzpicture}

% 2. if you simply have numerical content (as in your screenshot), add the following xticklabel=\strut... instruction: \begin{tikzpicture} \begin{axis}[xtick={1,2},xticklabel=\strut\pgfmathprintnumber{\tick}] \addplot {x}; \end{axis} \end{tikzpicture}

% 3. this here does also work: it uses the baseline as common alignment point and compensates the shifts explicitly: \begin{tikzpicture} \begin{axis}[xtick={1,2},xticklabels={g,G},xticklabel style={anchor=base,yshift=-\baselineskip}] \addplot {x}; \end{axis} \end{tikzpicture} \end{document}

I will think about a builtin solution for the next release (or the release after it).

Best regards

Christian

pgf-tikz-bot commented 10 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/45/#3d9a Author: cfeuersaenger Timestamp: 2014-04-30 15:35:22.200000

pgf-tikz-bot commented 10 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/45/#9c9b Author: cfeuersaenger Timestamp: 2014-04-30 15:35:22.336000

I have fixed it; will become part of pgfplots 1.11 (if one uses \pgfplotsset{compat=1.11}).

I have added \strut to every tick label. This will increase the bounding box for the figures... I hope that's no bad idea.

pgf-tikz-bot commented 10 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/45/#cb33 Author: cfeuersaenger Timestamp: 2014-05-11 13:12:44.261000

I have reverted the modification of the default configuration: if I enable \strut for any ticklabel, the bounding box will be too large. This affects any normal axis and the special ones like polar axes even more.

For now, I have just added a further key "typeset ticklabels with strut" which allows to enable this in a simple way... not really the best solution. My plan was to detect mismatches in the text depth/height and provide a meaningful warning. But that has its own challenges as it might disable "align" and "text width" for such labels.