# pgfplots - bar chart with bars starting at -120 instead of 0

I would like a plot like the one here shown (wanted) As using ybar, the origin is fixed at 0, I'm getting a plot with the bars starting from zero instead of -120.

• You mean the problem is about representation of [-120,-90] ? So your Y-axis is not in this range ? Could you show us some codes ? Sep 15, 2016 at 18:28
• ploting this using tikzpicture \ybar I m getting bar whichs start from 0, instead from -120. Sep 15, 2016 at 18:50
• You want to change the sign of your data ? Sep 16, 2016 at 7:59
• Can you post the code for your plot as a MWE? Sep 16, 2016 at 7:59

You can shift the labels with an offset

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
a b c
1 10 20
2 45 130
3 30 60
}\mytable
\begin{document}
\begin{tikzpicture}
\begin{axis}[ybar,xtick=data,enlarge y limits={upper=5},ymin=0,
yticklabel={\pgfmathparse{\tick-120}\pgfmathprintnumber{\pgfmathresult}}]
\end{axis}
\end{tikzpicture}
\end{document}


You can use ymax and ymin in the axis properties. Consider following samples. Without setting parameters (Commented lines):

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
ybar=15,
%ymin=0,
%ymax=120,
symbolic x coords={a small bar,a medium bar,a large bar},
xtick=data]
(a small bar,42)
(a medium bar,50)
(a large bar,80)
};
\end{axis}
\end{tikzpicture}

\end{document}


Uncomment the lines and you will have different ranges for Y-axis:

• getting same results with your code. Bars should be draw from -120 up to data level. Sep 15, 2016 at 19:50
• You can change the ymax and ymin value according to your problem. Sep 15, 2016 at 19:55
• thank you. but the problem is not range, but the bar origin point. Changing range will not affect the the bar origin, always they start from 0. The wanted chart is with bar staring from another value eg -120. Sep 16, 2016 at 3:59