改进基于 GeoGebra 文件的 TikZ 图片

改进基于 GeoGebra 文件的 TikZ 图片

我想对三次函数的固定点做一个小的图形说明。因此,我制作了一个 GeoGebra 文件,如下所示:在此处输入图片描述

基于我想要获得 TikZ 图片,因此 GeoGebra 创建了以下代码:

\documentclass[10pt]{article}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=3.393473219840507cm,y=3.1433709561724212cm, scale = 0.9, transform shape]
\begin{axis}[
x=3.393473219840507cm,y=3.1433709561724212cm,
axis lines=middle,
xmin=-1.3734914110429448,
xmax=1.62708588957055,
ymin=-1.1911483659319086,
ymax=1.353890101224171,
xtick={-1.0,0.0,1.0},
ytick={-1.0,0.0,1.0},]
\clip(-1.5734914110429448,-1.1911483659319086) rectangle (2.162708588957055,3.353890101224171);
\draw[line width=0.8pt,smooth,samples=100,domain=-1.5734914110429448:1.962708588957055] plot(\x,{(\x)^(3.0)});
\draw [line width=0.8pt,domain=-1.5734914110429448:1.962708588957055] plot(\x,{(-0.--1.*\x)/1.});
\draw (-1.3945119631901841,-0.6566295470542595) node[anchor=north west] {fixed point at $x = -1$};
\draw [->,line width=0.4pt] (-1.1269670132777865,-0.8093097675291255) -- (-1.0267447347382272,-0.9581246659666529);
\draw (1.1573010736196316,0.8952972509370971) node[anchor=north west] {fixed point at $x = 1$};
\draw (0.162066871165644,-0.20714781299805446) node[anchor=north west] {fixed point at $x = 0$};
\draw (1.3389923312883434,1.3508530624805482) node[anchor=north west] {$y = x $};
\draw (0.5803595092024538,1.3417419462496791) node[anchor=north west] {$f(x) = x^3$};
\draw (0.01834095092024525,1.36300121745504) node[anchor=north west] {$f(x)$};
\draw (1.5159338957055212,0.14514868126221436) node[anchor=north west] {$x$};
\draw [->,line width=0.4pt] (0.1593550613496931,-0.23144412294703853) -- (0.02376457055214709,-0.027962527124297032);
\draw [->,line width=0.4pt] (1.1491656441717788,0.843667592295506) -- (1.0298460122699384,0.9742602582712953);
\draw [line width=0.8pt,dash pattern=on 1pt off 1pt] (-1.,-1.)-- (-1.,0.);
\draw [line width=0.8pt,dash pattern=on 1pt off 1pt] (1.,1.)-- (1.,0.);
\begin{scriptsize}
\draw [fill=uuuuuu] (1.,1.) circle (2.0pt);
\draw [fill=uuuuuu] (-1.,-1.) circle (2.0pt);
\draw [fill=uuuuuu] (0.,0.) circle (2.0pt);
\end{scriptsize}
\end{axis}
\end{tikzpicture}
\end{document}

结果是

在此处输入图片描述

它看起来几乎就像我希望的那样,除了文本之外(固定点在...)。

我该如何改进代码,以便像图 1 中那样定位文本(固定点在…)(包括“at”后的换行符)?我尝试了一些小方法,但似乎没有任何效果。

答案1

这是一个提议。

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[>=stealth,scale=3]
\draw[->] (0,-1.2)--(0,1.4) node[below right] {$f(x)$};
\draw[->] (-1.6,0)--(2,0) node[above left] {$x$};
\draw[thick] plot[samples=2,domain=-1.2:1.4] (\x,\x);
\draw[thick] plot[smooth,samples=500,domain=-1.06:1.12] (\x,\x^3);
\fill (-1,-1) circle (.5pt) coordinate (a) (0,0) circle (.5pt) coordinate (b) (1,1) circle (.5pt) coordinate (c);
\draw[dashed] (-1,-1)--(-1,0) (1,0)--(1,1);
\draw (-1,-.03) node[below] {$-1$}--(-1,.03) (1,-.03) node[below] {$1$}--(1,.03);
\draw (-.03,-1) node[left] {$-1$}--(.03,-1) (-.03,1) node[left] {$1$}--(.03,1);
\draw (1.1,{1.1^3}) node[left] {$f(x)=x^3$};
\draw (1.3,1.3) node[below right] {$y=x$};
\draw[<-] ($(a)+(150:.05)$)--++(150:.2) node[above left,align=left] {fixed point\\at $x=-1$};
\draw[<-] ($(b)+(-30:.05)$)--++(-30:.2) node[below right,align=left] {fixed point\\at $x=0$};
\draw[<-] ($(c)+(-30:.05)$)--++(-30:.2) node[below right,align=left] {fixed point\\at $x=1$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

一些说明:

  • \draw plot即使没有,也能帮助我们绘制情节pgfplots
  • 图书馆calc帮助我们计算坐标。阅读更多这里
  • 节点可以是多行的,但是您需要添加对齐选项(align=...)和/或text width选项。阅读更多这里

相关内容