TransWikia.com

How to draw a complicated smooth curve

TeX - LaTeX Asked by user1942348 on April 18, 2021

I want to make each of the bending very smooth. Only criterion to draw the curve is that it starts from (1,2.5) and ends at (1,2.75). No equation of the curve given. I failed to do that. Please help.

documentclass[tikz,border=13mm]{standalone}
usetikzlibrary{arrows.meta,decorations.markings}
usetikzlibrary{calc}
%pgfplotsset{ticks=none}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
     begin{axis}[name=MyAxis,grid=major,grid style=dotted , xmin=0, xmax=12, ymin=0, ymax=5,
          xlabel=$xrightarrow$, ylabel={$y rightarrow$}, 
                  %xtick = {0,.3479,1},  xticklabels = {,$x_1$,},
                    %ytick = {0,0.015,0.0414,.4}, yticklabels={,,,},  %yticklabels=empty,
         scale=1, restrict y to domain=0:5,clip=false]
    draw  (1,0) -- (1,3);
    addplot[color=red,smooth,thick,-] coordinates  {
    (1,2.5) (.3,2) (1,.8) (5,0.5) (7,.75) (7.75,1.15) (8.25,1.75)  (8,2.5) (7,3) (5,3.2) (3.75,3.15) (2.5,3) (1,2.75)};
            end{axis}
end{tikzpicture}
end{document}

One Answer

You could draw[color=red] plot [smooth cycle] for a better result:

documentclass[tikz,border=13mm]{standalone}
usetikzlibrary{arrows.meta,decorations.markings}
usetikzlibrary{calc}
%pgfplotsset{ticks=none}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
    begin{tikzpicture}[>=stealth,declare function={f(x)=(10.5-x)/(10.5);}]
 begin{axis}[name=MyAxis,grid=major,grid style=dotted , xmin=0, xmax=12, ymin=0, ymax=5,
          xlabel=$xrightarrow$, ylabel={$y rightarrow$}, 
                  %xtick = {0,.3479,1},  xticklabels = {,$x_1$,},
                    %ytick = {0,0.015,0.0414,.4}, yticklabels={,,,},      %yticklabels=empty,
         scale=1, restrict y to domain=0:5,clip=false]
    draw  (1,0) -- (1,3);
    draw[color=red] plot [smooth cycle] coordinates {
(1,2.5) (.3,2) (1,.8) (5,0.5) (7,.75) (7.75,1.15) (8.25,1.75)  (8,2.5) (7,3) (5,3.2) (3.75,3.15) (2.5,3) (1,2.75)};
            end{axis}
end{tikzpicture}
end{document}

The result running in Gummi is: enter image description here

Without the line, the curve is: enter image description here

Original code posted by user1942348 without the line: enter image description here

Answered by DJP on April 18, 2021

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