I have bar charts that compare computation time of algorithms. The value above each bar represent the time and because they are bigger than they should be, some values are overlapped to graph or another bar.
I tried to rotate the value, but then it looks like the fig.
Is there any way to rotate different way so that some values can be inside the bar and some are not.
Here are my code.
\documentclass{article}
\usepackage{geometry}
\usepackage{pgfplots} % package used to implement the plot
\usetikzlibrary{pgfplots.groupplots}
\pgfplotsset{width=8.5cm, compat=1.6}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\hspace*{-2.1cm}%
\begin{tabular}{c@{\hspace{2.5cm}}c@{\hspace{2.5cm}}c@{\hspace{2.5cm}}c@{\hspace{2.5cm}}c}
\begin{axis}
[
width=3cm,
height=5.2cm,
ybar,
enlarge y limits=0.15,
enlarge x limits=0.3,
legend style={at={(0.4,-0.25)},
anchor=north,legend columns=-1},
ylabel= Execution Time (ms),
xlabel= number of points,
symbolic x coords={10K},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
nodes near coords style={anchor=east,rotate=-90,inner xsep=1pt},
]
\addplot coordinates {(10K, 0.369) };
\addplot coordinates {(10K, 0.325)};
\addplot coordinates {(10K, 0.302) };
\legend{}
\end{axis} &
\begin{axis}
[
width=3cm,
height=5.2cm,
ybar,
enlarge y limits=0.15,
enlarge x limits=0.3,
legend style={at={(0.4,-0.25)},
anchor=north,legend columns=-1},
ylabel= ,
symbolic x coords={100K},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(100K, 3.392) };
\addplot coordinates {(100K, 3.249)};
\addplot coordinates {(100K, 2.861) };
\legend{}
\end{axis} &
\begin{axis}
[
width=3cm,
height=5.2cm,
ybar,
enlarge y limits=0.15,
enlarge x limits=0.3,
legend style={at={(0.4,-0.25)},
anchor=north,legend columns=-1},
ylabel= ,
symbolic x coords={1M},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(1M, 34.729) };
\addplot coordinates {(1M, 33.818)};
\addplot coordinates {(1M, 29.640) };
\legend{Algo1, Algo2, Ours}
\end{axis} &
\begin{axis}
[
width=3cm,
height=5.2cm,
ybar,
enlarge y limits=0.15,
enlarge x limits=0.3,
legend style={at={(0.4,-0.25)},
anchor=north,legend columns=-1},
ylabel= ,
symbolic x coords={10M},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(10M, 387.236) };
\addplot coordinates {(10M, 332.314)};
\addplot coordinates {(10M, 278.019) };
\legend{}
\end{axis} &
\begin{axis}
[
width=3cm,
height=5.2cm,
ybar,
enlarge y limits=0.15,
enlarge x limits=0.3,
legend style={at={(0.4,-0.25)},
anchor=north,legend columns=-1},
ylabel= ,
symbolic x coords={100M},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(100M, 4195.304) };
\addplot coordinates {(100M, 3188.144)};
\addplot coordinates {(100M, 2683.925) };
\legend{}
\end{axis}
\end{tabular}
\end{tikzpicture}
\caption{\label{fig:comparison1}Average computation time in milliseconds for points in a square-boundary.}
\end{figure}
\end{document}



font=\tinyinsidenodes near coords style. – Torbjørn T. Nov 15 '21 at 19:02