你好,我想画出如附图所示的相图。但我在网上看到的一些例子非常不同(更复杂),当我选择一种方法来遵循时,我不知道如何像图片一样添加角度和字母。
以下是我目前所做的事情(第二张图片):
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}[>=latex]
\draw[style=help lines] (0,0) (3,2);
\coordinate (vec1) at (300:1.5);
\coordinate (vec2) at (30:2.5);
\coordinate (vec3) at (0:2.5);
\coordinate (vec4) at (90:2);
\coordinate (vec5) at (270:2);
\coordinate (vec6) at (180:2);
\draw[->,thick,black] (0,0) -- (vec1);
\draw[->,thick,black] (0,0) -- (vec2);
\draw[->,thick,black] (0,0) -- (vec3);
\draw[->,thick,black] (0,0) -- (vec4);
\draw[->,thick,black] (0,0) -- (vec5);
\draw[->,thick,black] (0,0) -- (vec6);
\end{tikzpicture}
\end{center}
\end document
答案1
了解arc
构造的最简单方法是首先使用详细模式。因此命令
\draw [red, thick] (1.0,0) arc [start angle=0, end angle=30, radius=1cm]
node [midway, right] {$\phi$};
表示使用提供的参数开始弧(1.0,0)
。更简洁的说法是使用
\draw [red, thick] (1.0,0) arc (0:30:1cm)
node [midway, right] {$\phi$};
其中,圆弧后面的参数是(<start angle>:<end angle>:<radius>)
。
代码:详细
\documentclass{article}
\usepackage{tikz}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}[>=latex]
\draw[style=help lines] (0,0) (3,2);
\coordinate (vec1) at (300:1.5);
\coordinate (vec2) at (30:2.5);
\coordinate (vec3) at (0:2.5);
\coordinate (vec4) at (90:2);
\coordinate (vec5) at (270:2);
\coordinate (vec6) at (180:2);
\draw[->,thick,black] (0,0) -- (vec1) node[right] {$I$};
\draw[->,thick,black] (0,0) -- (vec2) node[below right] {$V$};
\draw[->,thick,black] (0,0) -- (vec3) node [below] {$Re$};
\draw[->,thick,black] (0,0) -- (vec4) node [left] {$Im$};
\draw[->,thick,black] (0,0) -- (vec5);
\draw[->,thick,black] (0,0) -- (vec6);
\draw [red, thick] (1.0,0) arc [start angle=0, end angle=30, radius=1cm]
node [midway, right] {$\phi$};
\draw [blue, thick] (0.5,0) arc [start angle=0, end angle=-60, radius=0.5cm]
node [midway, right] {$\phi-\ang{90}$};
\end{tikzpicture}
\end{document}
代码:简洁:
\documentclass{article}
\usepackage{tikz}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}[>=latex]
\draw[style=help lines] (0,0) (3,2);
\coordinate (vec1) at (300:1.5);
\coordinate (vec2) at (30:2.5);
\coordinate (vec3) at (0:2.5);
\coordinate (vec4) at (90:2);
\coordinate (vec5) at (270:2);
\coordinate (vec6) at (180:2);
\draw[->,thick,black] (0,0) -- (vec1) node[right] {$I$};
\draw[->,thick,black] (0,0) -- (vec2) node[below right] {$V$};
\draw[->,thick,black] (0,0) -- (vec3) node [below] {$Re$};
\draw[->,thick,black] (0,0) -- (vec4) node [left] {$Im$};
\draw[->,thick,black] (0,0) -- (vec5);
\draw[->,thick,black] (0,0) -- (vec6);
\draw [red, thick ] (1.0,0) arc (0:30:1cm) node [midway, right] {$\phi$};
\draw [blue, thick] (0.5,0) arc (0:-60:0.5cm) node [midway, right] {$\phi-\ang{90}$};
\end{tikzpicture}
\end{document}
答案2
命令AngleMark
有几个选项可以以不同的方式标记角度。
\documentclass{article}
\usepackage{xparse,tikz,siunitx}
\usetikzlibrary{calc}
\pgfkeys{/tikz/.cd,
MarkAngleDim/.store in=\MarkAngleDim,
MarkAngleDim=0.5,
MarkDim/.store in=\MarkDim,
MarkDim=2,
}
\makeatletter
\NewDocumentCommand{\AngleMark}{%
d<> % secteur si vide ou traits avec le nombre de traits
O{} % options de dessin
m % liste des angles A/B/C
O{0} % nb de marques
D<>{7pt} % décalage du node
}{%
\foreach \Bn/\An/\Cn in {#3} {%
\pgfmathanglebetweenpoints%
{\pgfpointanchor{\An}{center}}%
{\pgfpointanchor{\Bn}{center}}%
\let\AnglA\pgfmathresult ;
\pgfmathanglebetweenpoints%
{\pgfpointanchor{\An}{center}}%
{\pgfpointanchor{\Cn}{center}}%
\let\AnglB\pgfmathresult ;
\pgfmathparse{ifthenelse(\AnglA>\AnglB,\AnglA-360,\AnglA)} \global\let\AnglA\pgfmathresult ;
\IfNoValueTF{#1}{% Secteur à remplir
\path[very thin,#2] (\An) --
($(\An) !\MarkAngleDim cm!(\Bn)$)
arc (\AnglA:\AnglB:\MarkAngleDim)
node[pos=.5] (@ngle\Bn\An\Cn) {}
--cycle;}{% Trait simple
\path[very thin,#2] ($(\An) !\MarkAngleDim cm!(\Bn)$)
arc (\AnglA:\AnglB:\MarkAngleDim)
node[pos=.5] (@ngle\Bn\An\Cn) {} ;
}
% Node de quotation sur l'arc
\node (Angle\Bn\An\Cn) at
($(@ngle\Bn\An\Cn)!-#5!(\An)$) {} ;
\ifnum#4>0
\pgfmathanglebetweenpoints%
{\pgfpointanchor{\An}{center}}%
{\pgfpointanchor{Angle\Bn\An\Cn}{center}}%
\let\AnglC\pgfmathresult ;
\begin{scope}[shift={(\An)}]
\foreach \i [evaluate=\i as \ang
using \AnglC+2*(\i-#4/2-.5)/\MarkAngleDim]
in {1,...,#4} {%
\draw[very thin,#2] (\ang:\MarkAngleDim cm +\MarkDim pt)
--(\ang:\MarkAngleDim cm -\MarkDim pt) ;
}
\end{scope}
\fi
}
}
\makeatother
\begin{document}
\begin{center}
\begin{tikzpicture}[>=latex]
\draw[style=help lines] (0,0) (3,2);
\coordinate (vec1) at (300:1.5);
\coordinate (vec2) at (30:2.5);
\coordinate (vec3) at (0:2.5);
\coordinate (vec4) at (90:2);
\coordinate (vec5) at (270:2);
\coordinate (vec6) at (180:2);
\draw[->,thick,black] (0,0) coordinate (O) -- (vec1);
\draw[->,thick,black] (0,0) -- (vec2);
\draw[->,thick,black] (0,0) -- (vec3);
\draw[->,thick,black] (0,0) -- (vec4);
\draw[->,thick,black] (0,0) -- (vec5);
\draw[->,thick,black] (0,0) -- (vec6);
\AngleMark[draw,MarkAngleDim=.8]{vec3/O/vec2}
\node at (Anglevec3Ovec2) {$\phi$};
\AngleMark[draw]{vec1/O/vec3}<0pt>
\node[anchor=north west] at (Anglevec1Ovec3) {$\theta=\phi-\ang{90}$};
\end{tikzpicture}
\end{center}
\end{document}
答案3
还有一个解决方案:
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows,arrows.meta,quotes,angles}
\usepackage{siunitx}
\begin{document}
%%%% se-phasor
\begin{tikzpicture}[
> = angle 90,
phasor/.style = {very thick,-{Triangle[fill=white]}},
angles/.style = {draw, <->, angle eccentricity=1,
right, angle radius=7mm}
]
% coordinates
\draw[->] (-0.5,0) -- (4,0) coordinate (x) node[below left] {$Re$};
\draw[->] (0,-1.5) -- (0,2) node[below left] (y) {$Im$};
% phasors
\draw[phasor] (0,0) -- (300:1.5) coordinate (i) node[right] {I};
\draw[phasor] (0,0) -- ( 30:2.5) coordinate (v) node[right] {V};
% angles drawn by pic
\coordinate (X) at (0,0);
\draw
pic["$\theta=\phi-\SI{90}{\degree}$",angles] {angle=i--X--x}
pic["$\phi$",angles] {angle=x--X--v}
;
\end{tikzpicture}
\end{document}
答案4
以下是原始图表的版本元帖子,文本采用 XITS 字体的 Times New Roman 格式,luamplib
包裹。
您必须使用 来处理此问题lualatex
,但此方法将 Unicode 和 OTF 字体处理带入纯 Metapost。请注意,您仍然可以根据需要重新定义事物(例如箭头)。
\documentclass[margin=1cm]{standalone}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{XITS}
\setmathfont{XITS Math}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
% redefine "_finarr" to get unfilled arrows
def _finarr text t =
draw _apth t;
unfill arrowhead _apth;
draw arrowhead _apth t
enddef;
beginfig(1);
path xx, yy, vv, ii;
% axes
yy = (40 down -- 40 up);
xx = (15 left -- 120 right);
drawarrow(xx); label.bot(btex \textit{Re} etex, point infinity of xx);
drawarrow(yy); label.lft(btex \textit{Im} etex, point infinity of yy);
% vectors
phi = 28;
theta = phi - 90;
vv = origin -- 90 right rotated phi;
ii = origin -- 40 right rotated theta;
drawarrow(vv); label.rt(btex \textbf{V} etex, point infinity of vv);
drawarrow(ii); label.rt(btex \textbf{I} etex, point infinity of ii);
% angle marks
path angle_mark[];
angle_mark1 = fullcircle scaled 70 cutafter vv;
angle_mark2 = reverse fullcircle scaled 30 cutafter ii;
draw(angle_mark1);
draw(angle_mark2);
label.rt(btex $ϕ$ etex, point .5 of angle_mark1 + 2 up);
label.rt(btex $θ=ϕ-90°$ etex, point .5 of angle_mark2 + 4 down);
endfig;
\end{mplibcode}
\end{document}