$y = \dfrac{21 x + 9}{x+9}$
我想画出函数和$A(-13, 66)$
、、和的$B(1, 3)$
图形。我使用 Geogebra 来绘制。这是我的代码$C(-69, 24)$
$G(-27, 31)$
\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{qqqqff}{rgb}{0,0,1}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[->,color=black] (-76.11,0) -- (66.76,0);
\foreach \x in {-70,-60,-50,-40,-30,-20,-10,10,20,30,40,50,60}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
\draw[->,color=black] (0,-2.85) -- (0,71.31);
\foreach \y in {,10,20,30,40,50,60,70}
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
\draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$};
\clip(-76.11,-2.85) rectangle (66.76,71.31);
\draw[smooth,samples=100,domain=-76.10871873047131:66.75686693800155] plot(\x,{(21*(\x)+9)/((\x)+9)});
\draw (-13,66)-- (1,3);
\draw (1,3)-- (-69,24);
\draw (-69,24)-- (-13,66);
\begin{scriptsize}
\fill [color=qqqqff] (-13,66) circle (1.5pt);
\draw[color=qqqqff] (-12.13,67.71) node {$A$};
\fill [color=qqqqff] (1,3) circle (1.5pt);
\draw[color=qqqqff] (3.4,3.23) node {$B$};
\fill [color=qqqqff] (-69,24) circle (1.5pt);
\draw[color=qqqqff] (-69.52,21.5) node {$C$};
\fill [color=qqqqff] (-27,31) circle (1.5pt);
\draw[color=qqqqff] (-26.17,28.33) node {$G$};
\end{scriptsize}
\end{tikzpicture}
\end{document}
图片中的点坐标太大,运行代码时无法查看,如何绘制此图?
答案1
当您使用x=1.0cm,y=1.0cm
单位长度时,节点\draw[color=qqqqff] (-69.52,21.5) node {$C$};
(例如)位于页面左侧 69.52 厘米处。这显然超出了页边距。因此,减少单位长度是必要的。您可以使用x=1.0mm,y=1.0mm
例如。
\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{qqqqff}{rgb}{0,0,1}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0mm,y=1.0mm] %%% <-- this line modified
\draw[->,color=black] (-76.11,0) -- (66.76,0);
\foreach \x in {-70,-60,-50,-40,-30,-20,-10,10,20,30,40,50,60}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
\draw[->,color=black] (0,-2.85) -- (0,71.31);
\foreach \y in {,10,20,30,40,50,60,70}
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
\draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$};
\clip(-76.11,-2.85) rectangle (66.76,71.31);
\draw[smooth,samples=100,domain=-76.10871873047131:66.75686693800155] plot(\x,{(21*(\x)+9)/((\x)+9)});
\draw (-13,66)-- (1,3);
\draw (1,3)-- (-69,24);
\draw (-69,24)-- (-13,66);
\begin{scriptsize}
\fill [color=qqqqff] (-13,66) circle (1.5pt);
\draw[color=qqqqff] (-12.13,67.71) node {$A$};
\fill [color=qqqqff] (1,3) circle (1.5pt);
\draw[color=qqqqff] (3.4,3.23) node {$B$};
\fill [color=qqqqff] (-69,24) circle (1.5pt);
\draw[color=qqqqff] (-69.52,21.5) node {$C$};
\fill [color=qqqqff] (-27,31) circle (1.5pt);
\draw[color=qqqqff] (-26.17,28.33) node {$G$};
\end{scriptsize}
\end{tikzpicture}
\end{document}
答案2
无需使用 GeoGebra 进行冗长的输出。
\documentclass[pstricks,border=15pt]{standalone}
\usepackage{pst-plot,pst-eucl}
\psset{algebraic,unit=1mm}
\def\f[#1]{(21*#1+9)/(#1+9)}
%\def\f[#1]{(21*(#1)+9)/(#1+9)}% <--- it is still valid for \f[a+b]
\begin{document}
\begin{pspicture}(-70,-10)(70,70)
\pstGeonode[PosAngle={45,-45,-90,-45}]
(*-13 \f[x]){A}
(*3 \f[x]){B}
(*-60 \f[x]){C}
(*-30 \f[x]){D}
\psaxes[Dx=10,Dy=10]{->}(0,0)(-70,-10)(70,70)[$x$,0][$y$,90]
\psplot[yMaxValue=70,yMinValue=-10,plotpoints=1500,linecolor=blue]{-70}{70}{\f[x]}
\pspolygon[linestyle=dashed](A)(B)(C)
\end{pspicture}
\end{document}