10 用找点法拟合下面的图象时,图象光滑度不是很满意

发布于 2025-07-06 16:14:18
\documentclass[border=2pt,tikz]{standalone}
\usepackage{tkz-euclide}
\tikzset{%
    every picture/.style={%
        samples=300,%
        smooth,%
        line join=round,%
        font=\small,%
        thick,>={Stealth[]}%
    }%
}%
\begin{document}
\begin{tikzpicture}
   \draw[->] (-2.5,0) -- (3,0) node[below] {$x$};
   \draw[->] (0,-2) -- (0,2) node[right] {$y$};
   \coordinate[label=-45:$O$] (O);
   \tkzDefPoints{-2.39/0.27/A,-2/0/B,-1.15/-0.73/C,-0.55/0/D,-0.21/0.51/E,0/0/F,0.21/0.51/G,0.55/0/H,1.15/-0.73/I,2/0/J,2.39/0.27/K}
   \draw plot[smooth,tension=.7] coordinates{(A)(B)(C)(D)(E)(F)(G)(H)(I)(J)(K)};
\end{tikzpicture}
\end{document}

333.jpg

image.png

查看更多

关注者
0
被浏览
104
Sagittarius Rover
Sagittarius Rover 10小时前
我要成为Typst糕手/(ㄒoㄒ)/~~

如果要取点,增加取点的数量/缩小取点的间隙是不是就可以解决「图象光滑度不是很满意」的问题呢?

related:


Claim:我不喜欢大量依赖「绝对坐标」的「可维护性差的」做法,上面

\tkzDefPoints{-2.39/0.27/A,-2/0/B,-1.15/-0.73/C,-0.55/0/D,-0.21/0.51/E,0/0/F,0.21/0.51/G,0.55/0/H,1.15/-0.73/I,2/0/J,2.39/0.27/K}
\draw plot[smooth,tension=.7] coordinates{(A)(B)(C)(D)(E)(F)(G)(H)(I)(J)(K)};

的丑陋语法让我难以接受...所以我 不打算用取点法

Learning From this link:

\documentclass[border=5pt,tikz]{standalone}
\tikzset{line join=round,line cap=round,thick}%
\newcommand*\myhalfpath[1][black]{%
    \draw[#1] (0,0)
    .. controls (.1,1) and (.6,1) .. (.8,0)
    .. controls (1.2,-1.75) and (1.6,-1.2) .. (2.8,0)
    .. controls (2.9,.1) and (3.1,.18) .. (3.2,.2)
    ;
}
\begin{document}
\begin{tikzpicture}
   \draw[-latex] (-3.25,0) -- (3.25,0) node[below] {$x$};
   \draw[-latex] (0,-2) -- (0,2) node[right] {$y$};
   \begin{scope}[xscale=-1]
        \myhalfpath[magenta]
   \end{scope}
   \myhalfpath[magenta]
\end{tikzpicture}

\begin{tikzpicture}
    \draw[-latex] (-3.25,0) -- (3.25,0) node[below] {$x$};
    \draw[-latex] (0,-2) -- (0,2) node[right] {$y$};
    \myhalfpath[cyan]
    \begin{scope}[scale=-1]
        \myhalfpath[cyan]
    \end{scope}
 \end{tikzpicture}
\end{document}

image.png

如果还是不光滑就自己微调吧....

@u1680

And, 希望OP可以从上面的这些提问中总结一套「此类函数绘制题」各个思路的对比和局限性的介绍,不然经常需要重复提问类似的问题。

3 个回答
mike
mike 8小时前
这家伙很懒,什么也没写!

确实是的,如果找不到合理的解决方案后面还会有各种不会画的图。

mike
mike 10小时前
这家伙很懒,什么也没写!

谢谢!如果能猜到A项是哪个函数自然是最佳的,但我没有猜到那个函数是什么
我试试增加点的个数看看

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览