TransWikia.com

Tikzpicture: Drawing a graph with curved and straight parts

TeX - LaTeX Asked by le_wofl on December 16, 2020

I am trying to produce a graph displaying concentration vs. time for a chemical equilibrium. These graphs look something like this (though note that this is just an example, not what I specifically want to produce):

enter image description here

I’m using the following code for my own graph:

...
pgfplotsset{compat=1.11}
...

begin{document}

begin{tikzpicture}[scale=1]
    begin{axis}[x post scale=1, y post scale=1, xmin=0, xmax=9, ymin=0, ymax=7, axis lines=left,
    restrict x to domain=0:8, enlargelimits=false, legend style={anchor=north, at={(0.5,1)}}, legend columns={2},
    ylabel={Concentration}, xlabel={Time (min)}, xtick={0, 1, 2, 3, 4, 5, 6, 7, 8}, ytick=empty]
        draw plot [smooth, domain=0:8, samples=50] coordinates {
            (0,0)
            (3,3)
            (5,3)
            (7,1)
            (8,1)
        };
    end{axis}
end{tikzpicture}

end{document}

This is what it produces:

enter image description here

In contrast, this is what I want (without the parts in red):

Is there a way to force the curve to flatten itself into a straight line between two coordinates, so that I can produce something like what is depicted in the second image above?

One Answer

like this?

begin{tikzpicture}

draw (0,0) .. controls (1.5,1.5) and (2.3,3) .. (3,3) .. controls (4,3) and (4,3) .. (5,3) .. controls (5.5,3) and (6.6,1) .. (7,1) .. controls (7.5,1) and (7.5,1) .. (8,1);
end{tikzpicture}

enter image description here

Change (2.3,3) to (2.5,3) and see the result. this makes it more flatten if you want.

Correct answer by user108724 on December 16, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP