如何绘制带有标签和网格的矢量?

如何绘制带有标签和网格的矢量?

[![在此处输入图片描述][1]][1]我想将此网格放入文档中。但编译后,网格似乎超出范围。这是我的代码:

\documentclass[10pt]{article}
\usepackage{pstricks-add}
\pagestyle{empty}
\begin{document}
\newrgbcolor{ttqqqq}{0.2 0 0}
\newrgbcolor{ffvvqq}{1 0.3333333333333333 0}
\psset{xunit=.3cm,yunit=.3cm,algebraic=true,dimen=middle,dotstyle=o,dotsize=5pt 0,linewidth=1.6pt,arrowsize=3pt 2,arrowinset=0.25}
\begin{pspicture*}(-65.13952272980184,-73.04198685498632)(131.54227288116022,14.655307681913095)
\multips(0,-73)(0,10){9}{\psline[linestyle=dashed,linecap=1,dash=1.5pt 1.5pt,linewidth=0.4pt,linecolor=ttqqqq]{c-c}(-65.13952272980184,0)(131.54227288116022,0)}
\multips(-65,0)(10,0){20}{\psline[linestyle=dashed,linecap=1,dash=1.5pt 1.5pt,linewidth=0.4pt,linecolor=ttqqqq]{c-c}(0,-73.04198685498632)(0,14.655307681913095)}
\psline[linewidth=2pt,linecolor=red]{->}(70,0)(70,-15)
\psline[linewidth=2pt,linestyle=dotted,linecolor=blue]{->}(0,0)(-15,0)
\psline[linewidth=2pt]{->}(80,0)(95,0)
\psline[linewidth=2pt,linecolor=green]{->}(85,-25)(75,-30)
\psline[linewidth=2pt,linestyle=dotted,linecolor=blue]{->}(0,0)(15,0)
\psline[linewidth=2pt,linestyle=dotted,linecolor=red]{->}(15,0)(15,-15)
\psline[linewidth=2pt,linestyle=dotted,linecolor=green]{->}(15,-15)(5,-20)
\psline[linewidth=2pt]{->}(0,0)(5,-20)
\psline[linewidth=2pt]{->}(0,0)(0,-10)
\psline[linewidth=2pt,linestyle=dotted]{->}(0,0)(0,-15)
\psline[linewidth=2pt,linestyle=dotted,linecolor=red]{->}(0,-15)(0,-30)
\psline[linewidth=2pt,linestyle=dotted,linecolor=red]{->}(0,-30)(0,-45)
\psline[linewidth=2pt,linestyle=dotted,linecolor=red]{->}(0,-45)(0,-60)
\psline[linewidth=2pt,linestyle=dotted,linecolor=blue]{->}(0,-60)(15,-60)
\psline[linewidth=2pt,linestyle=dotted,linecolor=blue]{->}(15,-60)(30,-60)
\psline[linewidth=2pt,linestyle=dotted,linecolor=blue]{->}(30,-60)(45,-60)
\psline[linewidth=2pt,linestyle=dotted,linecolor=blue]{->}(45,-60)(60,-60)
\psline[linewidth=2pt,linestyle=dotted,linecolor=green]{->}(60,-60)(70,-55)
\psline[linewidth=2pt,linestyle=dotted,linecolor=green]{->}(70,-55)(80,-50)
\psline[linewidth=2pt,linestyle=dotted]{->}(0,-60)(80,-50)
\begin{scriptsize}
\psdots[dotsize=4pt 0,dotstyle=*,linecolor=darkgray](0,0)
\rput[bl](0.6709256491709888,1.1634162146978002){$A$}
\rput[bl](70.52894146830843,-7.38144838120522){\red{$\vec{v}$}}
\psdots[dotstyle=*,linecolor=red](-15,0)
\rput[bl](-14.469974775148499,1.4632360250803622){\red{$B$}}
\rput[bl](-7.574119136349524,-0.6355026475975726){\blue{$-\vec{u}$}}
\rput[bl](87.4687607549233,0.713686499123957){$\vec{u}$}
\rput[bl](80.27308530574176,-28.069015297602007){\green{$\vec{w}$}}
\rput[bl](7.416871382778681,0.713686499123957){\blue{$\vec{u}$}}
\rput[bl](15.512006263107912,-7.38144838120522){\red{$\vec{v}$}}
\rput[bl](10.265159581413041,-18.025051649786175){\green{$\vec{w}$}}
\psdots[dotstyle=*,linecolor=red](5,-20)
\rput[bl](5.617952520483296,-18.47478136536002){\red{$M$}}
\rput[bl](3.069484132231502,-9.780006864265717){$\vec{u}+\vec{v}+\vec{w}$}
\psdots[dotstyle=*,linecolor=red](0,-10)
\rput[bl](0.6709256491709888,-8.430817717544187){\red{$R$}}
\rput[bl](0.5210157439797068,-7.38144838120522){$\dfrac23\vec{v}$}
\rput[bl](0.5210157439797068,-22.37243890033333){\red{$\vec{v}$}}
\rput[bl](0.5210157439797068,-37.36342941946143){\red{$\vec{v}$}}
\rput[bl](0.5210157439797068,-52.35441993858954){\red{$\vec{v}$}}
\rput[bl](7.416871382778681,-59.250275577388464){\blue{$\vec{u}$}}
\rput[bl](22.407861901906887,-59.250275577388464){\blue{$\vec{u}$}}
\rput[bl](37.398852421035095,-59.250275577388464){\blue{$\vec{u}$}}
\rput[bl](52.3898429401633,-59.250275577388464){\blue{$\vec{u}$}}
\rput[bl](64.68245516584842,-56.851717094327974){\green{$-\vec{w}$}}
\rput[bl](74.57650890847304,-51.9046902230157){\green{$-\vec{w}$}}
\psdots[dotstyle=*,linecolor=ffvvqq](80,-50)
\rput[bl](80.57290511612432,-48.45676240361623){\ffvvqq{$D$}}
\rput[bl](39.79741090409561,-54.30324870607619){$4\vec{u}-2\vec{w}$}
\psdots[dotstyle=*,linecolor=ffvvqq](0,-60)
\rput[bl](0.6709256491709888,-58.50072605143206){\ffvvqq{$C$}}
\psdots[dotsize=4pt 0,dotstyle=*,linecolor=ffvvqq](40,-55)
\rput[bl](40.54696043005202,-53.85351899050235){\ffvvqq{$T$}}
\end{scriptsize}
\end{pspicture*}
\end{document}

它必须看起来像下面这张图片,例如,它应该调整为 20x20。谢谢。

使用 @marmot 方法和 tikz 我有这个。如何将其中一些向量置于虚线样式?这是新代码:

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.misc} 
\usepackage{contour}
\contourlength{1pt}
\begin{document}
\begin{tikzpicture}[scale=0.4,>=stealth]
 \draw (0,0) grid (25,25) 
  (5,23) node[cross out,draw,thick,label={[anchor=south west]above:\contour{white}{$A$}}]{};
  \draw (2,23) node[cross out,draw,thick,label={[anchor=south west]above:\contour{white}{$B$}}]{};
  \draw (5,11) node[cross out,draw,thick,label={[anchor=south west]above:\contour{white}{$C$}}]{};
 \draw[thick,red,->] (16,23) -- ++(0,-3) node[midway,right] {\contour{white}{$\vec u$}};
 \draw[thick,blue,->] (18,23) -- ++(3,0) node[midway,above] {\contour{white}{$\vec v$}};
 \draw[thick,green!70!black,->] (18,19) -- ++(-2,-1) node[midway,above] {\contour{white}{$\vec w$}};
 \draw[thick,blue,->] (5,23) -- ++(-3,0) node[midway,above] {\contour{white}{$-\vec v$}};
 \draw[thick,red,->] (5,23) -- ++(0,-3) node[midway,right] {\contour{white}{$\vec u$}};
 \draw[thick,red,->] (5,20) -- ++(0,-3) node[midway,right] {\contour{white}{$\vec u$}};
 \draw[thick,red,->] (5,17) -- ++(0,-3) node[midway,right] {\contour{white}{$\vec u$}};
 \draw[thick,red,->] (5,14) -- ++(0,-3) node[midway,right] {\contour{white}{$\vec u$}};
 \draw[thick,blue,->] (5,20) -- ++(3,0) node[midway,above]
 {\contour{white}{$\vec v$}};
 \draw[thick,green!70!black,->] (8,20) -- ++(2,1) node[midway,above] {\contour{white}{$-\vec w$}};
 \draw[thick,gray!70!black,->] (5,23) -- ++(5,-2) node[midway,above]
 {\contour{white}{}};
 \draw (10,21) node[cross out,draw,thick,label={[anchor=south west]above:\contour{white}{$M$}}]{};
 \draw[thick,blue,->] (5,23) -- ++(2,0) node[midway,above] {\contour{white}{}};
 \draw (7,23) node[cross out,draw,thick,label={[anchor=south west]above:\contour{white}{$R$}}]{};
  \draw[thick,blue,->] (5,11) -- ++(3,0) node[midway,above] {\contour{white}{$\vec v$}};
  \draw[thick,blue,->] (8,11) -- ++(3,0) node[midway,above] {\contour{white}{$\vec v$}};
  \draw[thick,blue,->] (11,11) -- ++(3,0) node[midway,above] {\contour{white}{$\vec v$}};
  \draw[thick,blue,->] (14,11) -- ++(3,0) node[midway,above] {\contour{white}{$\vec v$}};
  \draw[thick,green!70!black,->] (17,11) -- ++(2,1) node[midway,above] {\contour{white}{$-\vec w$}};
  \draw[thick,green!70!black,->] (19,12) -- ++(2,1) node[midway,above] {\contour{white}{$-\vec w$}};
  \draw (21,13) node[cross out,draw,thick,label={[anchor=south west]above:\contour{white}{$D$}}]{};
   \draw[thick,gray!70!black,->] (5,11) -- ++(16,2) node[midway,above] {\contour{white}{}};
   \draw (13,12) node[cross out,draw,thick,label={[anchor=south west]above:\contour{white}{$D$}}]{};
\end{tikzpicture}
\end{document}```

And we get this:
[![enter image description here][2]][2]


[![enter image description here][3]][3]


  [1]: https://i.stack.imgur.com/meEi8.jpg
  [2]: https://i.stack.imgur.com/NGRwQ.jpg
  [3]: https://i.stack.imgur.com/yKl8j.jpg

答案1

仅用于与 Ti 的“比较”目的Z。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.misc} 
\usepackage{contour}
\contourlength{1pt}
\begin{document}
\begin{tikzpicture}[scale=0.4,>=stealth]
 \draw (0,0) grid (25,25) 
  (5,23) node[cross out,draw,thick,label={[anchor=south west]above:\contour{white}{$A$}}]{};
 \draw[thick,red,->] (16,23) -- ++(0,-3) node[midway,right] {\contour{white}{$\vec u$}};
 \draw[thick,blue,->] (18,23) -- ++(3,0) node[midway,above] {\contour{white}{$\vec v$}};
 \draw[thick,green!70!black,->] (18,19) -- ++(-2,-1) node[midway,above] {\contour{white}{$\vec w$}};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

一个简单的代码pstricks

\documentclass[border=10pt]{standalone}
\usepackage{amsmath}
\usepackage{pstricks-add, pst-eucl}

\begin{document}

\psset{unit =6mm}
\begin{pspicture}(0,0)(28,24)%
\psaxes[axesstyle=frame, labels=none, ticks =none](0,0)(28,24)
\psgrid[subgriddiv=1, gridlabels=0, griddots=10](0,0)(28,24)
\pstGeonode[PointSymbol=x, PosAngle=90, dotscale =2](5,22){A}
\pnodes(19,22){R}(19,19){S}(21,22){B}(24,22){C}(22,18){G}(20,17){H}
\psset{linewidth=1.2pt, arrows=->, arrowinset=0.12}
\ncline[linecolor=red]{R}{S}\naput{$\color{red}\vec{u}$}
\ncline[linecolor=blue]{B}{C}\naput{$\color{blue}\vec{v}$}
\ncline[linecolor=green]{G}{H}\nbput{$\color{green}\vec{w}$}
\end{pspicture}

\end{document} 

在此处输入图片描述

答案3

另一个简短版本:

\documentclass[border=10pt,pstricks]{standalone}
\usepackage{pst-node}
\begin{document}

\psset{unit=6mm}
\newpsstyle{gridstyle}{subgriddiv=1, gridlabels=0, griddots=10, gridcolor=black!20}
\begin{pspicture}[showgrid](0,0)(28,24)%
\psframe(28,24)
\psdot[dotstyle=x,dotscale=2](5,22)\uput[90](5,22){$A$}
\psset{linewidth=1.2pt, arrows=->, arrowinset=0.12, shortput=nab}
\pcline[linecolor=red](19,22)(19,19)^{$\color{red}\vec{u}$}
\pcline[linecolor=blue](21,22)(24,22)^{$\color{blue}\vec{v}$}
\pcline[linecolor=green](22,18)(20,17)_{$\color{green}\vec{w}$}
\end{pspicture}

\end{document} 

在此处输入图片描述

相关内容