5

Here is my code:

\documentclass[12pt, border=0.5mm]{standalone}

\usepackage[T1]{fontenc}
\usepackage[sc]{mathpazo}    

\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}

\begin{document}

\begin{tikzpicture}[x=1mm, y=1mm]       
    \pgfplotsset{
        every axis/.append style={
            line width=0.2mm
        },  
        every tick/.style={
            color=black,
            line width=0.1mm,
        },
        every tick label/.append style={
            font=\fontsize{7}{8}\selectfont
        }
    }

    \begin{axis}[
        axis on top,
        width=80mm,
        height=55mm,
        axis lines=middle,
        ymin=-14, ymax=45,
        xmin=-1, xmax=65,
        xtick={45, 50},
        xticklabels={$x$},
        extra x ticks={50},
        extra x tick labels={$x+h$},
        every extra x tick/.style={
            xticklabel style={yshift=0.6mm, xshift=1mm},
        },
        ytick=\empty,                   
    ]
        \addplot[blue, name path=f, line width=0.3mm, line cap=butt, samples=500, domain=0:60] 
            {sin(sinh(ln(50*(0.25*x + 2))))*(0.25*x + 2) + 25};

        \path[name path=axis] (axis cs:0,0) -- (axis cs:50,0);

        \addplot [color=blue, fill=blue, fill opacity=0.1]
            fill between[of=f and axis, soft clip={domain=0:45}];
        \addplot [color=red, fill=red, fill opacity=0.2]
            fill between[of=f and axis, soft clip={domain=45:50}];

        \node[font=\fontsize{7}{8}\selectfont, anchor=west] at (axis cs:10, 10) {area $= A(x)$};
        \node[font=\fontsize{7}{8}\selectfont, anchor=west] at (axis cs:2, -7) {$A(x+h)-A(x)\approx f(x)\cdot h$};
        \node[blue, font=\fontsize{7}{8}\selectfont, anchor=north] at (axis cs:10, 42) {$y=f(x)$};
        \node[font=\fontsize{7}{8}\selectfont, anchor=west] at (axis cs:53, 22) {Excess};       
        \draw[line width=0.1mm, stealth-] (axis cs:50.5, 22) -- (axis cs:54.2, 22);                 
        \draw[line width=0.1mm, decorate, decoration={brace, amplitude=3pt, mirror}, yshift=-4.5mm] (axis cs:45, 0) -- (axis cs:50, 0) node [midway, font=\fontsize{7}{8}\selectfont, yshift=-3mm] {$h$};           
        \draw[line width=0.1mm] (axis cs:45,{sin(sinh(ln(50*(0.25*45 + 2))))*(0.25*45 + 2) + 25}) rectangle (axis cs:50,{sin(sinh(ln(50*(0.25*50 + 2))))*(0.25*50 + 2) + 25});                  
    \end{axis}
\end{tikzpicture}                       
\end{document}

enter image description here

I would like to set ymin=-1 and at the same time avoid cropping and scaling of the plot as seen here:

enter image description here

Is there a way to do so?

  • 1
    \begin{axis}[clip=no,...? – Henri Menke Jul 14 '16 at 13:34
  • 1
    @HenriMenke clip=false. – Torbjørn T. Jul 14 '16 at 13:38
4

clip=false works like a charm!

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.