我希望它看起来像这样:
最好带有评论,这样我就可以学习如何制作自己的!
答案1
这应该可以帮助你入门:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
grid=major,
xmin=-5,
xmax=5,
ymin=-3,
ymax=5,
xlabel=$x$,
ylabel=$y$,
xtick={-4,-3,...,4},
ytick={-2,-1,...,4},
tick style={very thick},
legend style={
at={(rel axis cs:0,1)},
anchor=north west,draw=none,inner sep=0pt,fill=gray!10}
]
\addplot[blue,thick,samples=100] {x^2};
\addlegendentry{$y=x^2$}
\end{axis}
\end{tikzpicture}
\end{document}
在我看来,代码本身是不言自明的。有关详细信息,请texdoc pgfplots
从命令提示符/终端运行并查看pgfplots
手册。
答案2
只是为了让你开始。
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
%grid
\draw[step=1cm,gray!50,very thin] (-6.5,-4.5) grid (6.5,4.5);
%axes
\draw[very thick,->] (-6,0) -- (6,0) node[anchor=north west] {\bf{x axis}};
\draw[very thick,->] (0,-4) -- (0,4) node[anchor=south east] {\bf{y axis}};
\foreach \x in {1,2,3,4,5,6}
\draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {$\mathbf{\x}$};
\foreach \y in {1,2,3,4}
\draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east] {$\mathbf{\y}$};
%function
\draw[scale=0.5,domain=-3:3,smooth,variable=\x,blue,very thick] plot ({\x},{\x*\x});
\end{tikzpicture}
\end{document}