关于使用 Tikz 绘制坐标系和图形的多个问题

关于使用 Tikz 绘制坐标系和图形的多个问题

这是我第一次尝试在 LaTeX 中使用 Tikz,我不得不承认,使用 Tikz 可以做的事情太多了,如果我能慢慢详细地解释的话我会很感激。

到目前为止我尝试过的是这个帖子。但还有一些我想做的事情,但没有提到。其中包括

  • 绘制由函数(例如多项式)描述的图形并绘制与它们相交的垂直线,
  • 绘制坐标系不同的网格尺寸,
  • 标记坐标(而不仅仅是数字),
  • 在图上标记点,
  • 在某个位置使用大括号。

你可以在图片中找到我想要的结果(抱歉质量不好):

抱歉,质量不好!

你能帮我解决这个问题吗?我确实尝试按照上面的帖子自己做,但有太多事情需要考虑,我根本不知道从哪里开始。

多谢!

编辑:到目前为止,我尝试做的是复制另一段代码,并尝试了解这些函数的作用。这段代码中的一些内容可能对我的绘图有用:

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{arrows,intersections}
\begin{document}
\begin{tikzpicture}[
    thick,
    >=stealth',
    dot/.style = {
      draw,
      fill = white,
      circle,
      inner sep = 0pt,
      minimum size = 4pt
    }
  ]
  \coordinate (O) at (0,0);
  \draw[->] (-0.3,0) -- (8,0) coordinate (xmax);
  \draw[->] (0,-0.3) -- (0,5) coordinate (ymax);
  \path[name path=x] (0.4,0.5) -- (6.7,4.7);
  \path[name path=y] plot[smooth] coordinates {(-0.3,2) (2,1.5) (4,2.8) (6,5)};
  \scope[name intersections = {of = x and y, name = i}]
    \fill[gray!20] (i-1) -- (i-2 |- i-1) -- (i-2) -- cycle;
    \draw      (0.3,0.5) -- (6.7,4.7) node[pos=0.8, below right] {I don't even know where this belongs};
    \draw[blue] plot[smooth] coordinates {(1,2) (2,3) (4,2.5) (6,3.5)};
    \draw (i-1) node[dot, label = {above:$P$}] (i-1) {} -- node[left]
      {$f(x_0)$} (i-1 |- O) node[dot, label = {below:$x_0$}] {};
    \path (i-2) node[dot, label = {above:$Q$}] (i-2) {} -- (i-2 |- i-1)
      node[dot] (i-12) {};
    \draw           (i-12) -- (i-12 |- O) node[dot,
                              label = {below:$x_0 + \varepsilon$}] {};
    \draw[blue, <->] (i-2) -- node[right] {$f(x_0 + \varepsilon) - f(x_0)$}
                              (i-12);
    \draw[blue, <->] (i-1) -- node[below] {$\varepsilon$} (i-12);
    \path       (i-1 |- O) -- node[below] {$\varepsilon$} (i-2 |- O);
    \draw[gray]      (i-2) -- (i-2 -| xmax);
    \draw[gray, <->] ([xshift = -0.5cm]i-2 -| xmax) -- node[fill = white]
      {$f(x_0 + \varepsilon)$}  ([xshift = -0.5cm]xmax);
  \endscope
\end{tikzpicture}
\end{document}

据我所知,可以通过插值绘制多项式。到目前为止的结果如下:

在此处输入图片描述

答案1

我注释了很大一部分。其余部分大部分都是重复。

每当你看到类似 \path 的东西时,在方括号之间添加单词 draw 即可查看路径的样子。祝你好运!

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{arrows,intersections}
\begin{document}
    \begin{tikzpicture}[
    thick,                      % makes lines thick
    >=stealth',                 % chooses arrow type head
    dot/.style = {              % creates a new style called dot
        draw,                   % something to be drawn
        fill = white,           % fill color is white
        circle,                 % it's a circle
        inner sep = 0pt,        % no distance between contents and edge
        minimum size = 4pt      % don't make it smaller than 4 points, i.e. 1/18th of an inch
    }
    ]
    \coordinate (O) at (0,0);                                               % define O to be the origin
    \draw[->] (-0.3,0) -- (8,0) coordinate (xmax);                          % draw an arrow and call (8,0) xmax
    \draw[->] (0,-0.3) -- (0,5) coordinate (ymax);
    \path[name path=x] (0.4,0.5) -- (6.7,4.7);                  % label a path, but don't draw it; 
    \path[name path=y] plot[smooth] coordinates {(-0.3,2) (2,1.5) (4,2.8) (6,5)}; % ditto, but draw a smooth curve through it
    \scope[name intersections = {of = x and y, name = i}] 
    \fill[gray!20] (i-1) -- (i-2 |- i-1) -- (i-2) -- cycle;  % i-1 is the first intersection of x,y i-2 the second
    % so the command above fills the area from the first intersection point, drawing a horizontal line to the
    % x-coordinate of the second intersection point, up to the second intersection point and back to where we started
    \draw      (0.3,0.5) -- (6.7,4.7) node[pos=0.8, below right] {I don't even know where this belongs};
    % draw a line and at the point 80% of the way on this line segment, write
    % below and to the right "I don't even...."
    \draw[blue] plot[smooth] coordinates {(1,2) (2,3) (4,2.5) (6,3.5)};
    \draw (i-1) node[dot, label = {above:$P$}] (i-1) {} -- node[left]
    {$f(x_0)$} (i-1 |- O) node[dot, label = {below:$x_0$}] {};
    \path (i-2) node[dot, label = {above:$Q$}] (i-2) {} -- (i-2 |- i-1)
    node[dot] (i-12) {};
    \draw           (i-12) -- (i-12 |- O) node[dot,
    label = {below:$x_0 + \varepsilon$}] {};
    \draw[blue, <->] (i-2) -- node[right] {$f(x_0 + \varepsilon) - f(x_0)$}
    (i-12);
    \draw[blue, <->] (i-1) -- node[below] {$\varepsilon$} (i-12);
    \path       (i-1 |- O) -- node[below] {$\varepsilon$} (i-2 |- O);
    \draw[gray]      (i-2) -- (i-2 -| xmax);
    \draw[gray, <->] ([xshift = -0.5cm]i-2 -| xmax) -- node[fill = white]
    {$f(x_0 + \varepsilon)$}  ([xshift = -0.5cm]xmax);
    \endscope
    \end{tikzpicture}
\end{document}

相关内容