以下是我目前所得到的:
\documentclass[12pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x=1.0cm,y=1.0cm,
axis lines=middle,
xmin=-2,
xmax=4,
ymin=-2,
ymax=4,
xtick={-2.0,-1.0,...,4.0},
ytick={-2.0,-1.0,...,4.0},
]
%\draw [line width=.5pt,color=yellow,fill=yellow,fill opacity=0.11] (0,0) -- (0.:0.3) arc (0.:34:0.7) -- cycle;
\draw [shift={(-2,-2)},line width=.5pt,color=brown,fill=brown,fill opacity=0.11] (0,0) -- (0.:0.3) arc (0.:72:0.3) -- cycle;
\draw [shift={(-2,-2)},line width=.5pt,color=magenta,fill=magenta,fill opacity=0.11] (0,0) -- (33:0.3) arc (33:72:.4) -- cycle;
\draw [-latex] (0.,0.) -- (1.84,1.24);
\draw [-latex] (0.,0.) -- (0.82,2.54);
\begin{scriptsize}
\draw[color=black] (0.7,0.8) node {$\vec{u}$};
\draw[color=black] (0.3,1.52) node {$\vec{v}$};
%\draw[color=teal] (0.3,0.09) node {$\alpha$};
%\draw[color=red] (0.2,0.2) node {$\beta$};
%\draw[color=blue] (0.2,0.1) node {$\gamma$};
\end{scriptsize}
\end{axis}
\end{tikzpicture}
\end{document}
其结果如下:
我知道这三个角有相同的中心(点 [0;0]),但半径不同。我该如何实现?非常感谢!
答案1
该angles
库就是为此而设计的。使用该quotes
库还可以简化语法:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary {angles, quotes}
\begin{document}
\begin{tikzpicture}
\coordinate (o) at (0,0);
\coordinate (u) at (1.84,1.24);
\coordinate (v) at (0.82,2.54);
\coordinate (x) at (2,0);
\draw [-latex] (o) -- (u);
\draw [-latex] (o) -- (v);
\draw [-latex] (o) -- (x);
\path pic[draw=blue, angle radius=8mm, "$\alpha$", blue, angle eccentricity=.8]{angle=x--o--u};
\path pic[draw=red, angle radius=9mm, "$\beta$", red, angle eccentricity=.7]{angle=u--o--v};
\path pic[draw=teal, angle radius=10mm, "$\gamma$", below right, teal, angle eccentricity=1.1]{angle=x--o--v};
\end{tikzpicture}
\end{document}
答案2
像这样:
代码(角度单独计算):
\documentclass[10pt,a4paper]{article}
\usepackage{tikz,siunitx}
\sisetup{round-mode = places, round-precision = 1} % fix # of decimal places
\begin{document}
\begin{tikzpicture}[scale=2]
\draw[gray!20,step=.5] (-1,-1) grid (3,3);
\draw[thin,-latex] (-1,0)--(3,0) node[right] () {$x$};
\draw[thin,-latex] (0,-1)--(0,3) node[above] () {$y$};
\foreach \i in {-1,-.5,.5,1,...,3}{
\pgfmathsetmacro{\j}{\i}
\draw (\i,0)--(\i,-.1) node[below] () {\num{\j}};
}
\foreach \i in {-1,-.5,.5,1,...,3}{
\pgfmathsetmacro{\j}{\i}
\draw (0,\i)--(-.1,\i) node[left] () {\num{\j}};
}
\draw[line width=2pt,-latex] (0,0)--(1.84,1.24);
\draw[line width=2pt,-latex] (0,0)--(.82,2.54);
\draw[red] (1,0) arc(0:33.98:1) node[midway,fill=white] {\bfseries $\alpha$};
\draw[blue] (33.98:1.2) arc(33.98:72.11:1.2) node[midway,fill=white] {\bfseries $\beta$};
\end{tikzpicture}
\end{document}
如果您还想要这两个矢量的图例,请修改这两行:
\draw[line width=2pt,-latex] (0,0)--(1.84,1.24) node[above] {$\vec{u}$};
\draw[line width=2pt,-latex] (0,0)--(.82,2.54) node[above] {$\vec{v}$};
新输出:
答案3
另一种选择tkz-base
是tkz-euclide
代码
\documentclass{article}
%https://tex.stackexchange.com/questions/674228/tikz-arc-angles
\usepackage{tkz-base}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}[scale=1]
\tkzInit[xmin=-2,xmax=4,ymin=-2,ymax=4]
%\tkzGrid(-2,-2)(4,4)
\tkzLabelX[orig=false]
\tkzLabelY[orig=false]
\tkzDrawXY
%
\tkzDefPoints{0/0/O,1.84/1.24/A,0.82/2.54/B,2/0/x}
%
\tkzDrawSegments[vector style](O,A O,B)
\tkzLabelSegment[above,pos=.5](O,A){$\vec{u}$}
\tkzLabelSegment[above left=-0.5ex,pos=.5](O,B){$\vec{v}$}
%
\tkzMarkAngle[size=0.65,color=teal](x,O,A)
\tkzLabelAngle[pos=0.45,color=teal](x,O,A){$\alpha$}
\tkzMarkAngle[size=.8,color=red](A,O,B)
\tkzLabelAngle[pos=0.6,color=red](A,O,B){$\beta$}
\tkzMarkAngle[size=.95,color=blue](x,O,B)
\tkzLabelAngle[pos=1.15,color=blue,xshift=1ex,yshift=-1.5ex](x,O,B){$\gamma$}
\end{tikzpicture}
\end{document}