I'm trying to make a lot of different variations of PGFplots label styles so I'm trying to define different values and use \ticknum
to pick one of them for example
\newcommand{\x0}{0.3}
\newcommand{\x1}{0.5}
\newcommand{\x2}{0.7}
...
every x tick label/.style={
rotate=45,anchor=north east, text opacity=\x\ticknum,
},
But this gives me this error every time
! Undefined control sequence.\tikz@textopacity ->\x\ticknum \end{axis}
If this succeeds I also want to define different variables to change rotate
value for every x tick differently for example. How can I make this to work?
EDIT : This is what works like a charm with colors but I'm trying to make something like this to work with numeric values as well.
\definecolor{col0}{RGB}{0,0,255}
\definecolor{col1}{RGB}{255,0,0}
\definecolor{col2}{RGB}{0,255,0}
...
every extra x tick/.style={
grid=none,
tick label style={draw=col\ticknum},
},
This is a complete code
\documentclass{article}
\usepackage[a4paper,tmargin=5cm,bmargin=0cm,lmargin=0cm,rmargin=0.2cm,footskip=0cm]{geometry}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{adjustbox}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{adjustbox}{center}
\begin{tikzpicture}
\definecolor{COL0}{RGB}{255,0,0}
\definecolor{COL1}{RGB}{0,255,0}
\newcommand{\x0}{1}
\newcommand{\x1}{1}
\begin{axis}[
/pgfplots/ymin=0,
height=10cm,width=20cm,
ybar stacked,
/pgf/bar width=0.952381cm,
legend style={at={(0.5,0.98)},
anchor=north,legend columns=-1,font=\Large},
symbolic x coords={1,2},
xtick=data,
x=1.14286cm,
enlarge x limits={abs=0.666667cm},
every x tick label/.style={
rotate=45,anchor=north east, text opacity=1, inner sep=5pt %\x\ticknum (trying make this to work)
},
xticklabels={Text A,},
every extra x tick/.style={
grid=none,
tick label style={draw=COL\ticknum}, %Here this works
},
extra x ticks={2},
extra x tick labels={Text Extra},
]
\addplot+[fill=COL0,ybar] plot coordinates {(1,0.00519089)(2,0.0850676)};
\addplot+[fill=COL1,ybar] plot coordinates {(1,1.74808)(2,1.06387)};
\legend{\strut A,\strut B}
\end{axis}
\end{tikzpicture}
\end{adjustbox}
\end{document}
\foo
as\f\oo
even if you do\newcommand{\f}{f}\newcommand{\oo}{oo}
.\ticknum
? @egregtikzpicture
you want to draw.