使用 TikZ,我想创建一个描述直角坐标 (x,y) 的坐标平面。但是,我不确定如何做到这一点。这是我尝试执行的操作的示例:
但是,我只想要一个点,并保持 x 轴和 y 轴的图形。另外,我希望有一个表示坐标的变量,例如用 (x,y) 代替 (2,3)。最后,我希望在点所在的位置写上 (0,x) 和 (x,0),但不实际绘制点。
答案1
\documentclass[pstricks,margin=5mm]{standalone}
\usepackage{pst-plot,pst-eucl}
\begin{document}
\begin{pspicture}[](-3,-3)(6,6)
\psaxes{->}(0,0)(-3,-3)(5.5,5.5)[$x$,0][$y$,90]
\psset{PointNameSep=18pt,PosAngle=45,linestyle=dashed}
\pstGeonode[PointName=A{(3,3)},linecolor=red](3,3){A}
\psCoordinates[linecolor=red,showpoints=false](A)
\end{pspicture}
\end{document}
答案2
下次,请至少提供一些代码供大家使用。自动化、简化和修改留给读者练习。
\documentclass[border=10pt,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\path [draw, help lines, opacity=.5] (-11,-11) grid (11,11);
\foreach \i in {1,...,10} \draw (\i,2.5pt) -- +(0,-5pt) node [anchor=north, font=\small] {$\i$} (-\i,2.5pt) -- +(0,-5pt) node [anchor=north, font=\small] {$-\i$} (2.5pt,\i) -- +(-5pt,0) node [anchor=east, font=\small] {$\i$} (2.5pt,-\i) -- +(-5pt,0) node [anchor=east, font=\small] {$-\i$};
\draw [->] (-10,0) -- (10,0) node [anchor=south] {$x$};
\draw [->] (0,-10) -- (0,10) node [anchor=west] {$y$};
\path [draw=blue, ultra thick, text=blue, densely dashed] (0,6) node [anchor=south west] {$(0,y)$} -| (8,0) node [anchor=south west] {$(x,0)$} node [anchor=south west, midway] {$(x,y)$};
\end{tikzpicture}
\end{document}
答案3
这是使用 对图片的精确再现tkz-euclide
。
\documentclass[border=3]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
\tkzInit[xmin=-6,ymin=-6,xmax=6,ymax=6]
\tkzAxeXY
\tkzGrid
\tkzDefPoints{0/3/A,
2/3/B,
2/0/C}
\tkzDrawSegments[color=blue, ultra thick, densely dashed](A,B B,C)
\tkzDrawPoints[size=10,color=red](A,B,C)
\tkzLabelPoint[above right,color=blue](A){$(0,3)$}
\tkzLabelPoint[above right,color=blue](B){$(2,3)$}
\tkzLabelPoint[above right,color=blue](C){$(2,0)$}
\tkzDefPoints{0/1/D,
-3/1/E,
-3/0/F}
\tkzDrawSegments[color=red, ultra thick, densely dashed](D,E E,F)
\tkzDrawPoints[size=10,color=red](D,E,F)
\tkzLabelPoint[above left,color=blue](D){$(0,1)$}
\tkzLabelPoint[above left,color=blue](E){$(-3,1)$}
\tkzLabelPoint[above left,color=blue](F){$(-3,0)$}
\tkzDefPoints{0/-2.5/G,
-1.5/-2.5/H,
-1.5/0/I}
\tkzDrawSegments[color=red, ultra thick, densely dashed](G,H H,I)
\tkzDrawPoints[size=10,color=red](G,H,I)
\tkzLabelPoint[right,color=blue](G){$(0,-2.5)$}
\tkzLabelPoint[below,color=blue](H){$(-1.5,-2.5)$}
\tkzLabelPoint[above,color=blue](I){$(-1.5,0)$}
\tkzLabelPoint[above right,color=blue]({0,0}){$(0,0)$}
\end{tikzpicture}
\end{document}
由于这是重复代码,因此行数可以减少三分之二。但我将其保留得更详细,以便于理解。