1

I would like to know whether there is a solution when using this code in order to plot a chart like the image attached.

\begin{figure}[h!]
\begin{center}
\begin{tikzpicture}
\begin{axis}[
title= \large \textbf{Surge},
title style={yshift=1cm},
title style = {yshift=-5mm},
ylabel near ticks,
xlabel={Velocity [m/s]},
ylabel={Surge [N]}, 
height = 6cm, 
width = 13cm, 
grid = both,
xmin=0,xmax=45,
ymin=20000,ymax=40000,
xtick={0,5,...,45},
ytick={0,10000,...,80000},
legend style={at={(0.5,-0.35)},
        anchor=north,legend columns=-1}]

\addplot [mark=o,mark size=2,line width=1.5pt, red] table[x index=0,y     index=1, col sep=comma] {Surge.txt};
\addlegendentry{CFD}

\end{axis}
\end{tikzpicture}
\caption{Surge}.
\label{6}
\end{center}
\end{figure}

enter image description here

I am always getting this error: "Dimension too large \pgf@yy \end{axis}"

Is there any way to manage your axes when you have big differences with respect to axes ranges?

Thanks.

1
  • 1
    Without the datafile it is a bit hard to say, but the ytick range seems to be larger than the ymax, maybe that causes a problem.
    – Marijn
    Oct 26, 2015 at 10:57

1 Answer 1

2

As percusse explains in this post, it is caused by the <first>,<second>,...,<final> syntax of the y ticks. So you can either explicitely specify all tick values or specify the number of y ticks. Furthermore, if you want to prevent scientific notation for the y ticks, you can use scaled ticks=false. So here's how you could do it (as I don't have your data, a chose some function):

Code

\documentclass[tikz, border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12} 

\begin{document}

\begin{tikzpicture}
\begin{axis}
[   ylabel near ticks,
    height = 6cm, 
    width = 13cm, 
    grid = both,
    xmin=0,
    xmax=45,
    ymin=20000,
    ymax=80000,
    domain=0:45,
    samples=180,
    scaled ticks=false,
    xtick={0,5,...,45},
    ytick={0,20000,40000,60000,80000},
]
    \addplot [mark=o,mark size=2,line width=1.5pt, red] {95000*sin(x*20))};
\end{axis}
\end{tikzpicture}

\end{document}

Output

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .