TeX - LaTeX Asked by Tamay on August 15, 2021
When working with tikz, I’ve encountered this issue that I can’t get the axis labels to take up multiple lines. In some cases, the text on the axis is quite long, and so it becomes not very legible. In the example below, it would be better if the label
AAAAAAAAAAAA
was broken (i.e. extended vertically):
AAAAAA-
AAAAAA
How do you suggest I implement this change?
I have tried entering in AAAA//AAAA manually, but does not seem to be recognised by tikz.
begin{document}
centering
pgfplotstableread{
x y
AAAAAAAAAAAAAA 0.09
B 0.06
C 0.04
D 0.02
}{mytablee}
begin{tikzpicture}
begin{axis} [
ymin=0,
symbolic x coords={AAAAAAAAAAAAAA,B,C,D},
xtick=data
]
addplot
plot [mark=none, black, dashed]
table {mytablee};
end{axis}
node[above,font=largebfseries] at (current bounding box.north) {Test};
node[below,font=large] at (current bounding box.south) {Sample};
end{tikzpicture}
end{document}
By adding x tick label style={text width=1.7cm,align=center}
, your xtick label
s will wrap. You need the in the label to indicate the break point.
documentclass[border=3pt]{standalone}
usepackage{pgfplots}
pgfplotstableread{
x y
AAAAAAAAAAAAAA 0.09
B 0.06
C 0.04
D 0.02
}{mytablee}
begin{document}
begin{tikzpicture}
begin{axis} [
x tick label style={text width=1.7cm,align=center}, % <-- added
ymin=0,
symbolic x coords={AAAAAAAAAAAAAA,B,C,D},
xtick=data
]
addplot
plot [mark=none, black, dashed]
table {mytablee};
end{axis}
node[above,font=largebfseries] at (current bounding box.north) {Test};
node[below,font=large] at (current bounding box.south) {Sample};
end{tikzpicture}
end{document}
Correct answer by Ross on August 15, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP