\usepackage[paperheight=9in,paperwidth=7in, top=1in, bottom=0.8in, twocolumn, twoside]{geometry}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.70cm,y=0.70cm]
    axis lines=middle,
    \clip(-2.5,-0.5) rectangle (4.2,4.5);
    \draw[line width=1.0pt,smooth,samples=100,domain=-2.5:4.2] plot(\x,{(\x)^(2.0)});
    \draw[line width=1.0pt,smooth,samples=100,domain=-2.5:4.2] plot(\x,{(\x)^(4.0)});
    \draw[line width=1.0pt,smooth,samples=100,domain=-2.5:4.2] plot(\x,{(\x)^(6.0)});
    \draw [line width=1.0pt] (1.4070657529753525,1.9798340331960957)-- (2.593941214963645,1.978475622020055);
    \draw [line width=1.0pt] (1.2953304783336062,2.81528481157305)-- (3.041192850857456,2.80084143919352);
    \draw [line width=1.0pt] (1.2392646000958023,3.6222987404404536)-- (2.997910434480636,3.5943523154135297);
    \draw (2.6829479881822733,2.412164593764555) node[anchor=north west] {${\small y=x^2}$};
    \draw (2.9931087994563645,3.306157418205916) node[anchor=north west] {${\small y=x^4}$};
    \draw (2.9931087994563645,4.017702727455162) node[anchor=north west] {${\small y=x^6}$};

enter image description here

The tikzpicture is fit in the column not crossing the page anywhere, but still I am getting the error. I can't work with sizes bigger than about 19 feet. Continue and I'll use the largest value I can.

! Dimension too large. How can I fix this problem?

  • Pgfmath converts text to lengths to FPU registers and back again, with the limiting factor being lengths (32K or 100K). Easiest is to compute the data externally and read them in using pgfplotstable. There are also tricks using \pgfmathparsefpu (see tex.stackexchange.com/questions/545405/…) – John Kormylo Jul 11 at 18:01
  • @JohnKormylo Brother I need changes in tikzpicture code, I have share, The plot is fit and still I have problem of dimension too large, what to change in it? – Noor Aslam Jul 11 at 18:04
  • 1
    First of all, try to avoid using a^b. In general, a^b is computed using exp(b*log(a)) instead of a*a or a*a*a etc. That may not fix it, but it is far better from an applied math point of view. – John Kormylo Jul 12 at 19:10

Although the comments on your question are correct, the solution to your problem is easier.

You restrict the vertical axis with ymax but the draw commands you are using to plot have horizontal domains that (for the given functions) result in values that are far outside (above) the border of the picture that is actually printed. Hence, the error dimension too large.

Set domain=-2.3:2.3 and it all works fine.

| improve this answer | |

You can restricted function values, i.e. y, to domain defined by restrict y to domain=<min>:<max>:

\documentclass[twocolumn, twoside]{book}
            top=1in, bottom=0.8in]{geometry}


line cap=round, line join=round,
>=triangle 45]
    x=0.7 cm,y=0.7 cm,
    axis lines=middle,
    label style = {anchor=west},
    xmin=-3.3,  xmax=3.3,
    ymin=-0.5,  ymax=4.5,
    restrict y to domain=-0.5:4,    % <---
    no marks,
every axis plot post/.append style={line width=1.0pt, 
\addplot [name path=c2] {(x)^2};
\addplot [name path=c4] {(x)^4};
\addplot [name path=c6] {(x)^6};
\path [name path=C2] (0,3.5) -- (2.5,3.5);
\path [name path=C4] (0,3.0) -- (2.5,3.0);
\path [name path=C6] (0,2.5) -- (2.5,2.5);
\coordinate (n) at (2.5,0);
\draw [name intersections={of=c2 and C2, by=a}, <-]
        (a) -- (a -| n) node[right] {$y=x^2$};
\draw [name intersections={of=c4 and C4, by=b}, <-]
        (b) -- (b -| n) node[right] {$y=x^4$};
\draw [name intersections={of=c6 and C6, by=c}, <-]
        (c) -- (c -| n) node[right] {$y=x^6$};

As you can observe, the code for labeling of curves is written from scratch. It employ intersections TikZ library, so no need to manually calculated arrows for positioning of arrows and labels.

enter image description here

| improve this answer | |

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.