I'd like to replace numerical labels (e.g., 1,2,3,4,5) on x-axis with names (e.g., A,B,C,D,E
) in a group plot environment on a case-by-case basis. The group plot environment seems to easily support only a common x-axis across all group plots. How can I change the x-axis labels on the first plot to {A,B,C,D,E
}, and {F,G,H,I,S
} on the second plot?
I've purposefully titled my question to resemble the following post: TikZ: Replacing the values (labels) on x-axis with names
\documentclass[]{article}
\usepackage{pgfplots, alphalph}
\usepgfplotslibrary{groupplots}
\usepackage{filecontents}
\begin{filecontents*}{mydata.dat}
A B
1 3
2 4
3 1
4 7
5 8
\end{filecontents*}
\begin{filecontents*}{mydata2.dat}
C D
1 7
2 5
3 4
4 6
5 7
\end{filecontents*}
\begin{document}
\begin{figure}
\makebox[\textwidth]{%
\begin{tikzpicture}[font=\footnotesize\sffamily]
\begin{groupplot}[
group style={group size=2 by 1, vertical sep=70pt,
ylabels at=edge left
},
view={0}{90},
width=5.2cm,
height=5.2cm,
scale only axis,
scaled ticks = false,
tick label style={/pgf/number format/fixed},
xlabel={x-axis},
ylabel={y-axis},
unbounded coords=jump]
]
\nextgroupplot [title={\it{Title 1}}]
\addplot[black, thick, mark=o, only marks]
table[x=A,y=B]{mydata.dat};
\addplot[black, mark=x, only marks]
table[x=C,y=D]{mydata2.dat};
\nextgroupplot [title={\it{Title 2}}]
\addplot[black, thick, mark=o, only marks]
table[x=C,y=D]{mydata2.dat};
\end{groupplot}
\end{tikzpicture}
}
\end{figure}
\end{document}
I would like to learn how to create customized x-axis options (customized for each individual plot in group plot environment) instead of relying on common x-axis labels across the spectrum of plots in group plot.
Best Answer
You can use
in the options of
\nextgroupplot
. Changextick={1...,5},
as you wish. Further don't use\it{...}
as\it
is tex command and it doesn't take an argument. Use\itshape
as I did.Generally
\nextgroupplot
takes all options that are taken byaxis
environment. Hence you can customize all yourx axis
parameters here case by case.