1

This question already has an answer here:

I'd like to place two charts next to each other and have the y-axis scaled the same in both; that is, I'd like the y axis in this example to be from the minimum value, which is 10, to the maximum, 100, in both charts, so they can be more easily compared visually. Or would the best thing to be to put them in the same plot? If so, how can I separate the data visually?

(I got the code for doing the chart from Range chart by value)

enter image description here

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel near ticks,
xtick=data, % Only put labels at positions of data points
xticklabels={A,B,C}, % Provide text for labels
xlabel={Type},
ylabel={Value},
]
\addplot [
    only marks, % No lines between the points
    mark=empty, % No marks at the points
    error bars/y dir=plus,  % Error bars in the positive direction
    error bars/y explicit,  % We provide the values for the error bars
    error bars/error mark=empty,    % No markers at the end of the error bars
    error bars/error bar style={thick}  % Use thick lines for the error bars
] table [
    y error expr=\thisrow{Y2} - \thisrow{Y1} % Calculate the length of the error bars
] {
X Y1 Y2
1 10  30
2 20 40
3 30 45
};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
 xlabel near ticks,
xtick=data, % Only put labels at positions of data points
xticklabels={D,E,F}, % Provide text for labels
xlabel={Type},
ylabel={Value},
]
\addplot [
    only marks, % No lines between the points
    mark=empty, % No marks at the points
    error bars/y dir=plus,  % Error bars in the positive direction
    error bars/y explicit,  % We provide the values for the error bars
    error bars/error mark=empty,    % No markers at the end of the error bars
    error bars/error bar style={thick}  % Use thick lines for the error bars
] table [
    y error expr=\thisrow{Y2} - \thisrow{Y1} % Calculate the length of the error bars
] {
X Y1 Y2
1 60  80
2 70 80
3 90 100
};
\end{axis}
\end{tikzpicture}
\end{document}

marked as duplicate by Torbjørn T. tikz-pgf Oct 8 '15 at 20:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Just set ymin and ymax for each? (Or use a group plot, which does the same?) – Joseph Wright Jun 11 '15 at 17:31
  • @JosephWright Do you want to answer this one? – Torbjørn T. Jun 15 '15 at 18:32
  • @TorbjørnT. Not really: it's covered in the manual and is pretty easy to find. – Joseph Wright Jun 15 '15 at 20:49
  • If you put your comment as a reply, I can accept it? – alice19 Jun 16 '15 at 11:21
  • @marcellinus12 Note that people are generally not notified of comments unless you write @username, as you see me and Joseph did above. When you start typing the username after the @ you will see it appear in a small box, then you can hit the Tab-key to complete the name. – Torbjørn T. Jun 16 '15 at 21:26

Browse other questions tagged or ask your own question.