如何在不导入 geogebra 代码的情况下绘制此函数?

如何在不导入 geogebra 代码的情况下绘制此函数?

我如何才能在不使用 geogebra 并从该程序导出代码的情况下有效地绘制此函数?非常感谢

在此处输入图片描述

答案1

一个使用 的示例pgfplots,正​​如 Christian Hupfer 所建议的那样。

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots,pgfplotstable}
\pgfplotstableread{
x   y
0   0
1   2
2   4
3   6
4   8
7   8
9   10
}\mydata
\begin{document}
\begin{tikzpicture}
\begin{axis}[
  axis lines=middle,
  xlabel=$x$,ylabel=$y$,
  xmax=12,ymax=12,
  xtick={0,...,10},
  ytick={1,...,10}]

\addplot table[x=x,y=y] {\mydata};
\addplot [black!40,dashed,ycomb] table[x=x,y=y] {\mydata};
\addplot [black!40,dashed,xcomb] table[x=x,y=y] {\mydata};
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

我只是用 TikZ 画的。你可以从中学习TikZ 的简单介绍http://cremeronline.com/LaTeX/minimaltikz.pdf

\documentclass[12pt,a4paper]{article}
\usepackage{pgf,tikz}

\begin{document}
\begin{figure}[H]
\begin{tikzpicture}
   % Drawing Coordinate System. 
   \draw[help lines] (0,0) grid (10,10);
   \draw[ultra thick, ->] (0,0) -- (0,11); 
   \node[above] at (0,11) {$y$};
   \draw[ultra thick, ->] (0,0) -- (11,0); 
   \foreach \y in {,1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
   \draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {$\y$};
   \node[right] at (11,0) {$x$};
   \foreach \x in {,1,2,3,4,5,6,7,8,9,10}
   \draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {$\x$};

   % Drawing points. 
   \draw[fill] (0,0) circle [radius=3pt];
   \draw[fill] (1,2) circle [radius=3pt];
   \draw[fill] (3,6) circle [radius=3pt];
   \draw[fill] (4,8) circle [radius=3pt];
   \draw[fill] (7,8) circle [radius=3pt];
   \draw[fill] (9,10) circle [radius=3pt];

   % Drawing Lines. 
   \draw [thick] (0,0) -- (1,2);
   \draw [thick] (1,2) -- (2,4);
   \draw [thick] (2,4) -- (3,6);
   \draw [thick] (3,6) -- (4,8);
   \draw [thick] (4,8) -- (7,8);
   \draw [thick] (7,8) -- (9,10);

   % Drawing Dash Lines. 
   \draw [dashed] (0,2) -- (1,2) -- (1,0);
   \draw [dashed] (0,4) -- (2,4) -- (2,0);
   \draw [dashed] (0,6) -- (3,6) -- (3,0);
   \draw [dashed] (0,8) -- (4,8) -- (4,0);
   \draw [dashed] (7,8) -- (7,0);
   \draw [dashed] (0,10) -- (9,10) -- (9,0);
\end{tikzpicture}
\end{figure}

\end{document}

在此处输入图片描述

答案3

看看下面的代码,它应该能给你一些入门的想法。另请参阅以下示例示例

\documentclass{article} 
\usepackage[utf8]{inputenc}
\usepackage[landscape]{geometry}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\begin{document}


\begin{tikzpicture}[x=0.5cm,y=1cm]
\draw[step=1cm,lightgray,very thin] (0,0) grid (32,11);
\draw (0 cm,1pt) -- (0 cm,-1pt) node[anchor=north] {0};
\draw (3 cm,1pt) -- (3 cm,-1pt) node[anchor=north] {3};
\draw (4 cm,1pt) -- (4 cm,-1pt) node[anchor=north] {4};
\draw (7 cm,1pt) -- (7 cm,-1pt) node[anchor=north] {7};
\draw (10 cm,1pt) -- (10 cm,-1pt) node[anchor=north] {10};
\draw (12 cm,1pt) -- (12 cm,-1pt) node[anchor=north] {12};
\draw (14 cm,1pt) -- (14 cm,-1pt) node[anchor=north] {14};

\foreach \y in {1,2,3,4,5,6,7,8,9,10}
\draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east] {$\y0\% $};
\draw[black,ultra thick] (0,0) -- (6,2) -- (8,4)--(14,6)--(20,7) --(24,9)--(28,10)--(32,10);

\end{tikzpicture}

 \end{document}

在此处输入图片描述

相关内容