因此,我尝试在 Latex 中复制以下图像。以下是我发现难以实现的:
- 如何画一个小空心圆圈来表示我们有直角三角形,就像我试图复制的图像一样?
- 如何像图片一样绘制一个从 x 轴到三角形斜边的红色圆形箭头?
- 为什么围绕 x 轴的圆是断掉的?
非常感谢你们
\documentclass[11.5pt]{article}
\renewcommand{\familydefault}{\sfdefault}
\renewcommand{\sectionmark}[1]{\markright{#1}} %Gets rid of section number in the header%
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\usepackage{array}
\usepackage{float}
\usepackage{mathtools}
\usepackage{tikz}
\usepackage{bigints}
\usepgfplotslibrary{fillbetween}
\usepackage{subcaption}
\usepackage{pstricks}
\usepackage{fancyheadings}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{blindtext} %% to add dummy text
\renewcommand{\contentsname}{Table Of Contents}%
\begin{document}
\setlength{\parindent}{0cm}
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
title={$ $},
ticks=none
}}
% arrows as stealth fighters
\tikzset{>=stealth}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
xmin=-3,xmax=3,
ymin=-2.5,ymax=2.5,
]
\node [below] at (axis cs: 0.2, 0) {$O$};
\node [left] at (axis cs: -1.5, 1.3228) {$P$};
\node [below] at (axis cs: -0.7, 0) {$x$};
\node [left] at (axis cs: -1.5, 0.6) {$y$};
\node [above] at (axis cs: -0.7, 0.7) {$r$};
\node [right] at (axis cs: 0, 0.2) {$\theta$};
\plot[thick][samples=200,domain=-2.3:2.3] {sqrt(4-x^2)};
\plot[thick][samples=200,domain=-2.3:2.3] {-sqrt(4-x^2)};
\plot[ultra thick][samples=200,domain=-1.5:0] {0};
\plot[ultra thick][samples=200,domain=-1.5:0] {-0.881866*x};
\draw[style=ultra thick](axis cs:-1.5,0) -- (axis cs:-1.5,1.3228);
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
答案1
从头开始
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{angles,patterns,calc}
\begin{document}
\centering
\begin{tikzpicture}
\tikzset{>=stealth}
% draw axis and labels. We store a single coordinate to have the
% direction of the x axis
\draw[->] (-4,0) -- ++(8,0) coordinate (X) node[below] {$x$};
\draw[->] (0,-4) -- ++(0,8) node[left] {$y$};
\newcommand\CircleRadius{3cm}
\draw (0,0) circle (\CircleRadius);
% special method of noting the position of a point
\coordinate (P) at (140:\CircleRadius);
\draw[very thick,pattern=dots]
(0,0)
coordinate (O) % store origin
node[below right] {$O$} % label
--
node[above left,pos=1] {$P(x,y)$} % some labels
node[above right,midway] {$r$}
(P)
--
node[midway,left] {$y$}
(P |- O) coordinate (Px) % projection onto horizontal line through
% O, saved for later
--
node[midway,below] {$x$}
cycle % closed path
% pic trick is from the angles library, requires the three points of
% the marked angle to be named
pic [draw,red,->,angle radius=1cm,pic text=$\theta$,
angle eccentricity=1.3] {angle=X--O--P};
% right angle marker
\draw ($(Px)+(0.3,0)$) -- ++(0,0.3) -- ++(-0.3,0);
\end{tikzpicture}
\end{document}
答案2
\documentclass[border=2pt,tikz]{standalone}
\usetikzlibrary{calc,patterns,angles,quotes}
\begin{document}
\footnotesize
\begin{tikzpicture}[>=stealth, inner sep=2pt,scale=1.5]
\draw[->] (-1.5,0) --node[below right]{$O$} (1.5,0) coordinate[label=below:$x$](x);
\draw[->] (0,-1.5) -- (0,1.5) node[left]{$y$};;
\draw (0,0)coordinate(o) circle [radius=1cm];
\coordinate [label={left:$P(x,y)$}] (p) at (135:1);
\coordinate (q) at (p|-o);
\draw[thick,line join=round,pattern=dots] (o)--node[above]{$r$}(p)--node[left]{$y$}(q)--node[below]{$x$}(o)--cycle;
\pic[draw,"$\theta$",angle radius=15pt,angle eccentricity=1.3,->]{angle=x--o--p};
\draw ($(q)+(0.1,0)$) -- ++(0,0.1) -- ++(-0.1,0);
\end{tikzpicture}
\end{document}
答案3
另一种解决方案
\documentclass[border={10pt}]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,patterns}
\begin{document}
\begin{tikzpicture}[scale=2,>=stealth]
\draw[->,red] (3mm,0mm) arc (0:135:3mm) node[midway,xshift=2mm,yshift=2mm] {$\theta$};
\draw (0,0) circle (1cm);
\draw[fill=green,pattern=dots,pattern color=black!60!green]
node[below,xshift=2mm]{O} (0,0) -- node[above,black!60!green]{$r$} (135:1cm) node[left,xshift=2mm,yshift=2mm]{$\textbf{P}(x,y)$} -- node[left,black!60!green]{$y$} +(0,-0.707) -- node[below,black!60!green]{$x$} (0,0) -- cycle;
\draw[->] (-1.5,0) -- (1.5,0) node[anchor=west]{$x$};
\draw[->] (0,-1.5) -- (0,1.5) node[anchor=east]{$y$};
\draw (-.607,0) -- +(0,.1) -- +(-.1,0.1);
\end{tikzpicture}
\end{document}