
벤딩 하나하나를 매우 부드럽게 만들고 싶습니다. 곡선을 그리는 유일한 기준은 (1,2.5)에서 시작하여 (1,2.75)에서 끝나는 것입니다. 주어진 곡선의 방정식이 없습니다. 나는 그렇게 하지 못했습니다. 도와주세요.
\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=$x\rightarrow$, 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}
답변1
\draw[color=red] plot [smooth cycle]
더 나은 결과를 얻으려면 다음을 수행하십시오 .
\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=$x\rightarrow$, 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}
답변2
사용 hobby
:
\documentclass[tikz,border=13mm]{standalone}
\usetikzlibrary{arrows.meta,decorations.markings}
\usetikzlibrary{calc, hobby}
%\pgfplotsset{ticks=none}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[use Hobby shortcut]
\begin{axis}[name=MyAxis,grid=major,grid style=dotted , xmin=0, xmax=12, ymin=0, ymax=5,
xlabel=$x\rightarrow$, 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[red, thick] (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}
편집하다:
코드를 정리하고 더 적은 수의 포인트를 사용하여 곡선을 플롯으로 만들었습니다 \addplot
.
\documentclass[tikz,border=1cm]{standalone}
\usetikzlibrary{hobby}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[grid=major, grid style=dotted, xmin=0, xmax=12, ymin=0, ymax=5, xlabel=$x\rightarrow$, ylabel={$y \rightarrow$}]
\draw (1,0) -- (1,3);
\addplot[red, thick, smooth, hobby] coordinates {(1,2.5) (.3,2) (1,.8) (5,0.5) (7,.75) (8.25,1.75) (5,3.2) (1,2.75)};
\end{axis}
\end{tikzpicture}
\end{document}