I have following code by which I generate the following graph
\documentclass{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{arrows,automata,calc,shapes, positioning}
\makeatletter
\newcommand\resetstackedplots{
\makeatletter
\pgfplots@stacked@isfirstplottrue
\makeatother
\addplot [forget plot,draw=none] coordinates{(1,0) (5,0) (10,0) (15,0) (20,0)};
}
\makeatother
\begin{document}
\begin{tikzpicture}
\definecolor{satPointsColor}{HTML}{D7191C}
\definecolor{unsatPointsColor}{HTML}{FDAE61}
\definecolor{timedOutPointsColor}{HTML}{ABDDA4}
%\definecolor{rendering}{HTML}{2B83BA}
\begin{axis}[ybar stacked,
legend style={
legend columns=3,
at={(xticklabel cs:0.5)},
anchor=north,
draw=none
},
xtick=data,
bar width=2mm,
ymin=0,
axis y line*=none,
axis x line*=none,
tick label style={font=\footnotesize},
legend style={font=\footnotesize},
label style={font=\footnotesize},
xlabel style={yshift=-4ex},
xticklabel style={yshift=-10ex},
xlabel={$\alpha$},
ylabel={Total Points Explored},
area legend,
every node near coord/.append style={
anchor=east,
font=\tiny,
rotate=90}]
\addplot [bar shift=-0.3cm, satPointsColor,fill=satPointsColor,nodes near coords=2-clusters] table[x=Clusters,y=2] {satPoints.txt};
\addlegendentry{sat points};
\addplot [bar shift=-0.3cm, unsatPointsColor,fill=unsatPointsColor] table[x=Clusters,y=2] {unsatPoints.txt};
\addlegendentry{unsat points};
\addplot [bar shift=-0.3cm, timedOutPointsColor,fill=timedOutPointsColor] table[x=Clusters,y=2] {timedoutPoints.txt};
\addlegendentry{timed out points};
\resetstackedplots
\addplot [satPointsColor,fill=satPointsColor,nodes near coords=8-clusters] table[x=Clusters,y=8] {satPoints.txt};
\addplot [unsatPointsColor,fill=unsatPointsColor] table[x=Clusters,y=8] {unsatPoints.txt};
\addplot [timedOutPointsColor,fill=timedOutPointsColor] table[x=Clusters,y=8] {timedoutPoints.txt};
\resetstackedplots
\addplot [bar shift=0.3cm,satPointsColor,fill=satPointsColor,nodes near coords=16-clusters] table[x=Clusters,y=16] {satPoints.txt};
\addplot [bar shift=0.3cm, unsatPointsColor,fill=unsatPointsColor] table[x=Clusters,y=16] {unsatPoints.txt};
\addplot [bar shift=0.3cm, timedOutPointsColor,fill=timedOutPointsColor] table[x=Clusters,y=16] {timedoutPoints.txt};
\end{axis}
\end{tikzpicture}
\end{document}
satPoints.txt
Clusters 2 8 16
1 1 0 0
5 3 0 0
10 5 2 0
15 2 0 0
20 1 2 1
timedoutPoints.txt
Clusters 2 8 16
1 0 0 0
5 0 6 0
10 1 4 6
15 6 2 0
20 0 5 4
unsatPoints.txt
Clusters 2 8 16
1 5 9 9
5 37 8 9
10 49 8 3
15 3 3 1
20 4 4 5
Now we can see that the text Clusters-2, Clusters-8
and Clusters-16
is overlapping. I want to know what do I do to make it non-overlapping and appearing it under the bar? I think the problem is due to the bar shift
I added to the code.
Thanks !
==UPDATE==
I can make the code as follows –
\addplot [bar shift=-0.3cm, satPointsColor,fill=satPointsColor,nodes near coords=2-clusters,nodes={xshift=-3mm}] table[x=Clusters,y=2] {Figures/experiments/julien/satPoints.txt};
However, the labels are not well-aligned.
Best Answer
To solve the issue I suggest to rearrange the tables in the following way :
table.txt
and simplifying your original code (the only dirty part concerns the x label of 1,5,10,15,20 which are positioned manually) :