1

I'm a beginner with LaTeX. I use matlab2tikz to create a bar figure, but in LaTeX always shows Dimension too large.end{\axis}. I have no idea about that.

\begin{tikzpicture}
\begin{axis}[%
width=4in,
height=2.5in,
at={(0.634in,4.176in)},
scale only axis,
bar shift auto,
xmin=0,
xmax=24,
restrict y to domain= 0:5000,
xlabel style={font=\color{white!15!black}},
xlabel={Segments Number},
ymin=0,
ymax=4420,
ylabel style={font=\color{white!15!black}},
ylabel={Length},
axis background/.style={fill=white},
title style={font=\bfseries},
title={Group 1}
]
\addplot[ybar, bar width=0.9, fill=mycolor1, draw=black, area legend] table[row sep=crcr] {%
1   4000\\
2   4159\\
3   3217\\
4   3217\\
5   3004\\
6   3379\\
7   4320\\
8   3121\\
9   2796\\
10  3407\\
11  3919\\
12  3942\\
13  3619\\
14  1506\\
15  3506\\
16  3783\\
17  3451\\
18  3842\\
19  4127\\
20  3450\\
21  3246\\
22  3766\\
2   3196\\
};
\addplot[forget plot, color=white!15!black] table[row sep=crcr] {%
0   0\\
24  0\\
};
\addplot [color=red, dashed, forget plot]
  table[row sep=crcr]{%
14  0\\
14  1506\\
};
\addplot [color=red, dashed, forget plot]
  table[row sep=crcr]{%
0   1506\\
14  1506\\
};
\addplot [color=red, dashed, forget plot]
  table[row sep=crcr]{%
7   0\\
7   4320\\
};
\addplot [color=red, dashed, forget plot]
  table[row sep=crcr]{%
0   4320\\
7   4320\\
};
\addplot [color=blue, dashed, forget plot]
  table[row sep=crcr]{%
0   3477.08695652174\\
3477.08695652174    3477.08695652174\\
};
\node[above, align=center]
at (axis cs:12,3477) {Average Segments Length};
\end{axis}
3
  • 1
    ` Welcome to TeX.SX! Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass and ending with \end{document}.
    – Bobyandbob
    Sep 9 '17 at 16:12
  • Welcome to TeX.SX! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it).
    – dexteritas
    Sep 9 '17 at 16:12
  • 2
    The last plot has a very large x value. Without it the plots compiles fine. This looks like an error. Sep 11 '17 at 8:14
-1

Refering to the valid comment from Ulrike Fischer, you get a result with the following MWE:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{xcolor}

\begin{document}

\begin{tikzpicture}

    \begin{axis}[%
        width=4in,
        height=2.5in,
        at={(0.634in,4.176in)},
        scale only axis,
        bar shift auto,
        xmin=0,
        xmax=24,
        restrict y to domain= 0:5000,
        xlabel style={font=\color{white!15!black}},
        xlabel={Segments Number},
        ymin=0,
        ymax=4420,
        ylabel style={font=\color{white!15!black}},
        ylabel={Length},
        axis background/.style={fill=white},
        title style={font=\bfseries},
        title={Group 1}
    ]
\addplot[ybar, bar width=0.9, fill=blue, draw=black, area legend] table[row sep=crcr] {%
1   4000\\
2   4159\\
3   3217\\
4   3217\\
5   3004\\
6   3379\\
7   4320\\
8   3121\\
9   2796\\
10  3407\\
11  3919\\
12  3942\\
13  3619\\
14  1506\\
15  3506\\
16  3783\\
17  3451\\
18  3842\\
19  4127\\
20  3450\\
21  3246\\
22  3766\\
23  3196\\
};

\addplot [color=red, dashed, forget plot]
  table[row sep=crcr]{%
0   1506\\
14  1506\\
};


\addplot [color=red, dashed, forget plot]
  table[row sep=crcr]{%
0   4320\\
7   4320\\
};

\node[above, align=center, yshift=.6cm]
    at (axis cs:13,3477) {Average Segments Length};
\end{axis}

\end{tikzpicture}

\end{document}

enter image description here

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.