【发布时间】:2019-10-15 06:29:51
【问题描述】:
我正在使用"yticklabel style={rotate=90}" 将 pgfplot 中的 ytick 标签旋转 90°。标签的文本没有正确水平对齐。
在以下示例中,“Grouped”未与其他标签对齐(尤其是因为它包含“p”)。
图片:
我已经用完了“样式”选项来解决这个问题,知道如何让这些值水平对齐吗?谢谢!
编辑:
最小示例(请注意,我的实际代码使用标签来处理 CSV 文件中的列):
\documentclass{article}
% translate with >> pdflatex -shell-escape <file>
% This file is an extract of the PGFPLOTS manual, copyright by Christian Feuersaenger.
%
% Feel free to use it as long as you cite the pgfplots manual properly.
%
% See
% http://pgfplots.sourceforge.net/pgfplots.pdf
% for the complete manual.
%
% Any required input files (for <plot table> or <plot file> or the table package) can be downloaded
% at
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/
% and
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/plotdata/
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xbar, xmin=0,
width=12cm, height=5.5cm, enlarge y limits=0.5,
xlabel={\#participants},
symbolic y coords={Flat,Grouped},
ytick=data,
nodes near coords, nodes near coords align={horizontal},
yticklabel style={rotate=90},
]
\addplot coordinates {(3,Flat) (7,Grouped)};
\end{axis}
\end{tikzpicture}
\end{document}
【问题讨论】:
-
在标签中插入
\strut而不使用降序可能会有所帮助,但这只是一个猜测,只要没有示例代码可以测试
标签: latex