使用 Tikz 进行绘图

使用 Tikz 进行绘图

我有一张图片,我想画一张图片

在此处输入图片描述

答案1

欢迎来到 Tex.Se。这里有一些小东西可以开始:下次请提供 MWE。至少学习绝对值并不难基本,比如画一条线并表现出一些努力将会受到赞赏。

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
    
    \begin{tikzpicture}[inner sep=2pt]      
        
        \draw[-,yellow,thick] (0,0)--(8,8);
        \draw[->,gray,thick,>=stealth] (0,0)--(4,8);
        \draw[->,gray,thick,>=stealth] (0,0)--(8,4);
        \draw[->,very thick,>=stealth] (0,0)--(0,10);
        \draw[->,very thick,>=stealth] (0,0)--(10,0);
        

        \node[circle, draw=black, fill=black] (A) at (4,5) {};
        \node[circle, draw=none, above=of A,yshift=-1.2cm] (A1) at (4,5) {Event A};
        \node[circle,draw=none, right=of A] (B) at (1.2,1.1) {};
        \node[circle,draw=none, below left=of A] (C) at (3,5) {};
        \node[circle,red,rotate=45, draw=none] at (7,7.3) {Light curve};
        \node[circle,rotate=27, draw=none,text width=3.5cm] at (4,1.5) {\small Position of Event A \\  according to Observer 2};
        \node[circle,rotate=63, draw=none,text width=3.5cm] at (2,5) {\small Position of Event A \\ according to Observer 1};
            
        \draw [-,dashed] (A) -- (B);
        \draw [-,dashed] (A) -- (C);
     
    \end{tikzpicture}
    
\end{document}

在此处输入图片描述

答案2

还有一个解决方案,定义图像元素的样式,部分使用极坐标,使用quotes库来标记矢量和光变曲线。通过库intersections计算虚线的坐标,使它们与矢量平行:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                intersections,
                positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[
arr/.style = {draw=gray, -Stealth, thick},
dot/.style = {circle, fill, inner sep=2pt},
lbl/.style = {auto, align=left, inner sep=2pt, 
              pos=0.6, sloped, text=#1},
lbl/.default = black
                        ]
% axes
\draw[arr] (0,0) -- (0,8);
\draw[arr] (0,0) -- (8,0);
%  light line
\draw[yellow,thick]  (0,0) to[lbl=red,near end, "Light curve"] (8,8);
% vectors, used polar coordinates
\draw[arr, name path=V2] (0,0) 
        to[lbl, "Time of Event A\\  
                 according to observer 2"] (67.5:8);
\draw[arr, name path=V1] (0,0) 
        to[lbl, "Position of Event A\\  
                 according to observer 2" swap] (22.5:8);
% event
\node (d) [dot, label=Event A] at (4,5) {};
% dashed lines
\path[name path=A] (d) -- ++ (180+22.5:4);
\path[name path=B] (d) -- ++ (180+67.5:5);
\draw[name intersections={of=A and V2, by=a},
      densely dashed] (a) -- (d);
\draw[name intersections={of=B and V1, by=b},
      densely dashed] (b) -- (d);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案3

在此处输入图片描述

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,angles,quotes, arrows.meta}

\begin{document}
    \begin{tikzpicture}
    \coordinate (origo) at (0,0);
    \draw[thick, -Latex] (origo) -- ++(90:3) ;
    \draw[thick, -Latex] (origo) -- ++(0:3) ;
    \draw[thick, -Latex] (origo) -- ++(20:3) node[red, pos=0.7, below=-2pt, sloped ](thirty){\texttt{\tiny Text}};
    \draw[thick, -Latex] (origo) -- ++(70:3) node[red, pos=0.7, above=-2pt, sloped ]{\texttt{\tiny Text}};
    \draw[thick, yellow, ] (origo) -- ++(45:5)node[red, pos=0.7, above=-2pt, sloped ]{\texttt{\tiny Light Curve}};    
    \path[ ] (origo) -- ++(55:1.5) coordinate (bob1);    
    \fill (bob1) circle(0.05)node[blue,above]{\texttt{\tiny Event A}};
    \path(origo)--++(20:1)coordinate(bob30);
    \path(origo)--++(70:1)coordinate(bob70);
    \draw[densely dashed](bob1)--(bob30);    
    \draw[densely dashed](bob1)--(bob70);    
    \end{tikzpicture}
\end{document}

相关内容