生成图片

生成图片

我正在尝试使用 Tikz 代码生成在 Geogebra 上创建的图片。 在此处输入图片描述

这张图片是我在玩一些函数时幸运得到的。现在,我使用以下代码在 Tikz 上生成图片,但它没有编译坐标。也许是其他原因导致它没有编译,我看不出来。

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[->,color=black] (0.7333308390918073,0.0) -- (5.239998617966438,0.0);
\foreach \x in {,1.0,2.0,3.0,4.0,5.0}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);
\clip(0.7333308390918073,-0.6933333333333337) rectangle (5.239998617966438,3.040000000000002);
\draw[smooth,samples=100,domain=2.0400031082342736:4.039997101821316] plot(\x, ((\x)-3.04)^(5)-2*((\x)-3.04)^(3)+(\x)-3.04+1.0]+0.66});
\draw [line width=1.2000000000000002pt,dash pattern=on 1pt off 1pt] (2.04,1.6600000000000001)-- (2.04,0.0);
\draw [line width=1.2000000000000002pt,dash pattern=on 1pt off 1pt] (4.04,1.6600000000000001)-- (4.04,0.0);
\draw (1.933331135241857,-0.026666666666666682) node[anchor=north west] {$a$};
\draw (3.9333316288252727,-0.04000000000000002) node[anchor=north west] {$\beta$};
\draw[smooth,samples=100,domain=4.066665128397554:5.066663234885912] plot(\x,((\x)-0.013333333333333641-5.05333)^(5)-2.0*((\x)-0.013333333333333641-5.05333)^(3)+(\x)-0.013333333333333641-5.05333-1.0]+1.8000033333333345});
\draw [line width=1.2000000000000002pt,dash pattern=on 1pt off 1pt] (2.04,1.6600000000000001)-- (2.04,2.84);
\draw[smooth,samples=100,domain=1.040000568108668:2.039999103789556] plot(\x, ((\x)-1.04)^(2)]+1.5733333333333346});
\begin{scriptsize}
\draw [fill=black] (2.04,1.6600000000000001) circle (1.5pt);
\draw [fill=black] (4.04,1.6600000000000001) circle (1.5pt);
\draw [color=black] (4.04,0.8181088825214906) circle (2.0pt);
\draw [color=black] (2.0399999999999996,2.5733333333333337) circle (2.0pt);
\end{scriptsize}
\end{tikzpicture}

有什么建议么?

顺便问一下,我们如何在 Tikz 中创建随机函数(图形)?谢谢!

答案1

绘制一个简化的尝试作为建议,并调试和添加 Geogebra 输出。对于后者,draw plotdash pattern=on 1pt off 1pt是错误的主要来源。

起点如何绘制随机函数在这儿。

在此处输入图片描述

代码

\documentclass[border=10pt,varwidth]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,calc,}
\begin{document}

Simplified equivalent 

\vspace{1cm}

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45]
\draw[-,color=black] (0,0) -- (6,0);
\foreach \x in {1.0,2.0,3.0,4.0,5.0}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);
\node[below] at (2,0){$\alpha$};
\node[below] at (4,0){$\beta$};
\draw [fill=black]    (2.0,1.66)coordinate(a) circle (1.5pt);
\draw [fill=black]    (4.0,1.66)coordinate(b) circle (1.5pt);
\draw [draw]   (4.0,0.82)coordinate(c) circle (2.0pt);
\draw [draw]   (2.0,2.57)coordinate(d) circle (2.0pt);

\draw ($(a)-(1,0)$) to[out=0,in=-100,looseness=0.5](d);
\draw (a) to[bend right=50,looseness=1.5]node[above]{$c_f$} ($(a)!0.5!(b)$) to[bend left=50,looseness=1.5] (b);
\draw (c) to[bend right=50, looseness=1.5] ++(1,0);
\draw[dashed](2,0)--(d);
\draw[dashed](4,0)--(b);
\end{tikzpicture}

\vspace{1cm}

Geogebra output, 

%dash pattern=on 1pt off 1pt is changed to dashed options

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[->,color=black] (0.7333308390918073,0.0) -- (5.239998617966438,0.0);
\foreach \x in {,1.0,2.0,3.0,4.0,5.0}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);
\clip(0.7333308390918073,-0.6933333333333337) rectangle (5.239998617966438,3.040000000000002);
\draw[smooth,samples=100,domain=2.0400031082342736:4.039997101821316] plot(\x, {((\x)-3.04)^(5)-2*((\x)-3.04)^(3)+(\x)-3.04+1.0+0.66});
\draw [line width=1.2000000000000002pt, dashed] (2.04,1.6600000000000001)-- (2.04,0.0);
\draw [line width=1.2000000000000002pt,dashed] (4.04,1.6600000000000001)-- (4.04,0.0);
\draw (1.933331135241857,-0.026666666666666682) node[anchor=north west] {$a$};
\draw (3.9333316288252727,-0.04000000000000002) node[anchor=north west] {$\beta$};
\draw[smooth,samples=100,domain=4.066665128397554:5.066663234885912] plot(\x,{((\x)-0.013333333333333641-5.05333)^(5)-2.0*((\x)-0.013333333333333641-5.05333)^(3)+(\x)-0.013333333333333641-5.05333-1.0+1.8000033333333345});
\draw [line width=1.2pt,dashed] (2.04,1.66)-- (2.04,2.84);
\draw[smooth,samples=100,domain=1.040000568108668:2.039999103789556] plot(\x,{((\x)-1.04)^(2)+1.5733333333333346});
\begin{scriptsize}
\draw [fill=black] (2.04,1.6600000000000001) circle (1.5pt);
\draw [fill=black] (4.04,1.6600000000000001) circle (1.5pt);
\draw [color=black] (4.04,0.8181088825214906) circle (2.0pt);
\draw [color=black] (2.0399999999999996,2.5733333333333337) circle (2.0pt);
\end{scriptsize}
\end{tikzpicture}

\end{document}

相关内容