Estou enfrentando um problema estranho ao gerar um gráfico de barras em pgfplots. No meu gráfico tenho muitos rótulos no eixo x, que tento girar 90 graus usando o comando xticklabel style={rotate=90,anchor=east}
. O problema é que, em vez de apenas girar os rótulos, isso resulta na rotação da página em 90 graus.
Como exemplo mínimo, considere o código a seguir que executei no verso.
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepgfplotslibrary{statistics}
\begin{document}
\pgfplotsset{width=12cm, height=10cm}
\begin{figure}[htb!]
\centering
\begin{tikzpicture}
\begin{axis}
[
axis y line=left,
axis x line*=bottom,
ymajorgrids,
ymax = 35,
ymin=0,
xmin= 0,
xmax=10,
x tick label style={font=\tiny},
xtick align=outside,
xtick=data,
xticklabels from table={data.txt}{group},
xticklabel style={rotate=90,anchor=east}
]
\addplot+[
ybar,
bar width=3pt,
mark=none,
color=blue,
fill=blue
] table[x=id,y=val] {data.txt};
\end{axis}
\end{tikzpicture}
\caption{Caption}
\label{fig:label}
\end{figure}
\end{document}
O arquivo data.txt:
id group val
1 DSDSJ 26.0
2 ABSDS 26.0
3 BB 31.0
4 CCCCC 25.0
5 DDDDS 21.0
6 DDDDD 19.0
7 DDDDD 19.0
8 DDDDD 19.0
Isso resulta no seguinte:
Observe que toda a página do pdf está sendo exibida girada. Você tem alguma ideia de por que isso está acontecendo e como consertar?
Agradeço antecipadamente.
Responder1
você precisa definir apenas
x tick label style={font=\tiny,rotate=90,anchor=east},
o xticklabel style={rotate=90,anchor=east}
é falso.
\RequirePackage{filecontents}
\begin{filecontents}{data.dat}
id group val
1 DSDSJ 26.0
2 ABSDS 26.0
3 BB 31.0
4 CCCCC 25.0
5 DDDDS 21.0
6 DDDDD 19.0
7 DDDDD 19.0
8 DDDDD 19.0
\end{filecontents}
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepgfplotslibrary{statistics}
\begin{document}
\pgfplotsset{width=12cm, height=10cm}
\begin{figure}[htb!]
\centering
\begin{tikzpicture}
\begin{axis}
[
axis y line=left,
axis x line*=bottom,
ymajorgrids,
ymax = 35,
ymin=0,
xmin= 0,
xmax=10,
x tick label style={font=\tiny,rotate=90,anchor=east},
xtick align=outside,
xtick=data,
xticklabels from table={data.dat}{group},
]
\addplot+[
ybar,
bar width=3pt,
mark=none,
color=blue,
fill=blue
] table[x=id,y=val] {data.dat};
\end{axis}
\end{tikzpicture}
\caption{Caption}
\label{fig:label}
\end{figure}
\end{document}