3

I have a bar chart with relatively large values and I am using the near coords option to show the values over the bars. I want the \times symbol instead of \cdot for pgfplots multiplier. I know how to change it for axis by /pgfplots/tick scale binop=\times but I am not sure if it is possible to do the same thing for the values shown over the bars.

\documentclass[10pt]{article}
\usepackage{pgfplots}

\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[/pgfplots/tick scale binop=\times,
title=128-bit,
ybar,
height=4.5in,
width=3.3in,
ymin=0,
legend style={at={(0.3,0.95)},anchor=north},
enlarge y limits={upper,value=0.5},
enlarge x limits=0.15,
height=2.5in,
bar width = 7pt,
major tick length=0cm,
nodes near coords,
symbolic x  coords={1NN,10NN,100NN},
xtick=data,
every node near coord/.append style={rotate=90, anchor=west},
]   
\addplot coordinates {(1NN,38751) (10NN,84295) (100NN,162122)};
\addplot coordinates {(1NN,17040) (10NN,55571) (100NN,175327)};
\addplot coordinates {(1NN,55791) (10NN,139866) (100NN,337449)};
\legend{$\#$ comp,$\#$ buck, Total}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

enter image description here

2

Crude quick hack:

\def\cdot{\times}

Or without disabling \cdot:
I have not found a configuration option. \cdot is hardcoded in the internal macro \pgfmathfloatrounddisplaystyle@std, which is assigned to \pgfmathfloatrounddisplaystyle. The following example file redefines these macros to use \times instead of \cdot. Also the y limit is enlarged a bit, because the numbers now need more space.

\documentclass[10pt]{article} \usepackage{pgfplots}

\makeatletter
\def\pgfmathfloatrounddisplaystyle@std#1#2e#3\relax{%
  \pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{\times}{}{10^{#3}}%
}
\let\pgfmathfloatrounddisplaystyle\pgfmathfloatrounddisplaystyle@std
\makeatother

\begin{document}
\makeatletter
\begin{figure}
\begin{tikzpicture}
\begin{axis}[
  /pgfplots/tick scale binop=\times,
  title=128-bit,
  ybar,
  height=4.5in,
  width=3.3in,
  ymin=0,
  legend style={at={(0.3,0.95)},anchor=north},
  enlarge y limits={upper,value=0.6},
  enlarge x limits=0.15,
  height=2.5in,
  bar width = 7pt,
  major tick length=0cm,
  nodes near coords,
  symbolic x  coords={1NN,10NN,100NN},
  xtick=data,
  every node near coord/.append style={rotate=90, anchor=west},
]
  \addplot coordinates {(1NN,38751) (10NN,84295) (100NN,162122)};
  \addplot coordinates {(1NN,17040) (10NN,55571) (100NN,175327)};
  \addplot coordinates {(1NN,55791) (10NN,139866) (100NN,337449)};
  \legend{$\#$ comp,$\#$ buck, Total}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

Result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.