Does anyone know how can i enter text into the x-axis ? It seems like only numbers are allowed as soon as i wanted to enter alphabets it will be an error.
This template was adapted from here.
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepgfplotslibrary{dateplot}
\pgfplotsset{ width=5cm,
compat=newest,
height=5cm}
\begin{document}
\pgfplotstableread{
Year OneCol SecCol ThirdCol ForthCol
2005 10 70 -10 30
2006 -40 60 -15 90
2007 -20 60 -15 60
}\datatable
\begin{tikzpicture}
\begin{axis}[
x tick label style={/pgf/number format/1000 sep=},
ybar stacked,
bar width=1em,
ymin=-100,
ymax=200,
legend style={
at={(0.5,-0.1)},
anchor=north,
draw=none },
restrict y to domain*=:0, % negative values
y=1pt, % important workaround!
]
\addplot table [y index=1] {\datatable};
\addplot table [y index=2] {\datatable};
\addplot table [y index=3] {\datatable};
\addplot table [y index=4] {\datatable};
\legend{Factor1,Factor2,Factor3,Factor4}
\end{axis}
\begin{axis}[
x tick label style={/pgf/number format/1000 sep=},
ybar stacked,
bar width=1em,
ymin=-100,
ymax=200,
legend style={
at={(0.5,-0.1)},
anchor=north,
draw=none },
restrict y to domain*=0:, % positive values
y=1pt, % important workaround!
]
\addplot table [y index=1] {\datatable};
\addplot table [y index=2] {\datatable};
\addplot table [y index=3] {\datatable};
\addplot table [y index=4] {\datatable};
\legend{Factor1,Factor2,Factor3,Factor4}
\end{axis}
\end{tikzpicture}
\end{document}
symbolic x coords
, or usexticklabels={A, B, C}
.xticklabels from table
could be another option: tex.stackexchange.com/questions/63335/…xtick=data
as well.