tikz 中文本在一行上方的位置以及覆盖一行的位置

tikz 中文本在一行上方的位置以及覆盖一行的位置

我在 tikz 中绘制了这个圆,你可以看到$v_m$x 轴和 y 轴上的 不可见,而且 也$V_me^{j\theta}$未与线对齐。还请注意,虽然圆弧的角度为 50 度,就像线的方向一样,但它显示的角度并不正确

在此处输入图片描述

这些是我正在使用的命令

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{xcolor}
\definecolor{lava}{rgb}{0.81, 0.06, 0.13}
\definecolor{myblue}{rgb}{0.0, 0.30, 0.60}
\usepackage{gensymb}

\begin{document}
    \begin{tikzpicture}
        
        % Axis
        \draw[thick,->,black] (-3,0)--(3,0) node[below] {$\Re$}; % x axis
        \draw[thick,->,black] (0,-2.5)--(0,3) node[left] {$\Im$}; % y axis
        %circle
        \draw[black,thick] (0,0) circle (2.5cm);
        %defining radius points
        \node[black,below] at (2.6,0) {$V_m$};
        \filldraw[black] (2.5,0) circle (2pt);
        \node[black,below] at (0,2.6) {$V_m$};
        \filldraw[black] (0,2.5) circle (2pt);
           
        \draw[ultra thick,->,lava] (0,0) -- (0,0 |- 45:2.5cm)node [black,midway,sloped,above](b1){$V_m\sin(\phi)$}; % UpOn x axis
        \draw[ultra thick,->,myblue] (0,0) -- (45:2.5cm |- 0,0)node [black,midway,sloped,below](b){$V_m \cos (\phi)$}; % UpOn y axis
        \draw[ultra thick,black,->,rotate=45] (0,0) -- (2.5,0)node [black,midway,sloped,above](b5){$V_me^{j\theta}$}; 
        \draw[thick,black](50:2cm |- 0,0) arc (0:50:2);
        \node[] at (20:1.25cm |-20:1.25cm ) {$\phi$}; 
    \end{tikzpicture}
\end{document}

答案1

使用 MWE,所有标签都可见,但是,它们与圆重叠,并且不沿矢量对齐。通过使用label标记节点名称(参见下面的 MWE)并使用sloped矢量标签选项angles可以纠正此问题。此外,使用库可以简化角度的绘制和标记:

%\documentclass[12pt]{article}
\documentclass[12pt, margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{angles, arrows.meta,    % new
                quotes}                 % new
\definecolor{lava}{rgb}{0.81, 0.06, 0.13}
\definecolor{myblue}{rgb}{0.0, 0.30, 0.60}
%\usepackage{gensymb} % better is to use siunitx

\begin{document}
    \begin{tikzpicture}[
ang/.style = {draw, Straight Barb-Straight Barb, anchor=west,
              angle radius = 8mm, angle eccentricity=1},
arr/.style = {cap=round,-Straight Barb},
dot/.style = {circle, fill, minimum size=3pt,inner sep=0pt},
every edge quotes/.style = {auto, font=\footnotesize, sloped},
every label/.style       = {inner sep=1pt},
                        ]
% axis
\draw[arr]  (-2.7,0)--(3.6,0)   node[below] {$\Re$}; % x axis
\draw[arr]  (0,-2.7)--(0,3) node[left]  {$\Im$}; % y axis
% circle
\draw       (0,0) circle (2.5cm);
% defining radius points
\node (n1) [dot,label= 45:$V_m$] at (90:2.5) {};
\node (n2) [dot,label= 45:$P$]   at (45:2.5) {};
\node (n3) [dot,label=-45:$V_m$] at ( 0:2.5) {};
% vector
\coordinate (O) at (0,0);
\path[draw=lava, ultra thick, arr] 
    (O) to ["$V_m\mathrm{e}^{j\theta}$"]  (n2.center);
% projections
\path[draw=myblue, very thick, arr] 
    (O) to ["$V_m \cos(\phi)$" ']   (n2.center |- O); % projection on x axis
\path[draw=myblue, very thick, arr]
    (O) to ["$V_m \sin(\phi)$"]     (n2.center -| O); % projection on y axis
% angle
\pic [ang, "$\omega t+\phi$"] {angle = n3--O--n2};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

在此处输入图片描述

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{xcolor} 
 \definecolor{lava}{rgb}{0.81, 0.06, 0.13} 
 \definecolor{myblue}{rgb}{0.0, 0.30, 0.60} 
\usepackage{gensymb}

\begin{document}
    \begin{tikzpicture}
    
    % Axis
    \draw[thick,->,black] (-3,0)--(3,0) node[below] {$\Re$}; % x axis
    \draw[thick,->,black] (0,-2.5)--(0,3) node[left] {$\Im$}; % y axis
    %circle
    \draw[black,thick] (0,0) circle (2.5cm);
    %defining radius points
    \node[circle,fill=red,inner sep=0pt,minimum size=4pt,label=45:{$V_m$}] at (2.5,0) 
      {};
    \node[circle,fill=red,inner sep=0pt,minimum size=4pt,label=45:{$V_m$}] at (0,2.5) 
      {};
    \draw[ultra thick,->,lava] (0,0) -- (0,0 |- 45:2.5cm)node 
    [black,midway,sloped,above](b1){\scriptsize $V_m\sin(\phi)$}; % UpOn x axis
    \draw[ultra thick,->,myblue] (0,0) -- (45:2.5cm |- 0,0)node 
    [black,midway,sloped,below](b){\scriptsize $V_m \cos (\phi)$}; % UpOn y axis
    \draw[ultra thick,black,->,rotate=45] (0,0) -- (2.5,0)node 
    [black,midway,rotate=45,above](b5){\scriptsize $V_me^{j\theta}$}; 
    \path[]  (45:1cm |-45:1cm ) edge  [bend left=30]   (45:1cm |- 0,0) ;
    \node[]at  (20:1.25cm |-20:1.25cm ) {$\phi$}; 
    \end{tikzpicture}
\end{document}

相关内容