我想畫一條曲線,給人一種軸映射到另一個軸的印象,上面有希臘字符 rho,如下圖所示。
我還希望在軸的交點處有一個小正方形,給人以該角度是直角的印象。
到目前為止,我有以下程式碼(部分來自本網站已有的一些程式碼)。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=.5]
\draw [dashed] (2,2) -- (4, 4);
\draw [->] (4, 4) -- (5.5, 5.5);
\draw [dashed] (2,2) -- (-.25, 3.678) ;
\draw [->] (-.25, 3.687) -- (-2, 5);
\draw (2,2) circle (3cm);
\draw[dashed] (2,2) ellipse (3cm and 1cm);
\clip (-1.1,2) rectangle (5.1 cm, 0.9 cm);
\draw (2,2) ellipse (3cm and 1cm);
\end{tikzpicture}
\end{center}
\end{document}
答案1
如果您使用極座標製作圖表,則可以使用 來arc
繪製該箭頭。下面的程式碼中有一些註釋,詢問您是否需要更多說明。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}[
declare function={
R=2cm; % radius
theta=45; % angle of right arrow
}]
% draw circle, and place coordinate at center
\draw (1,1) coordinate (O) circle[radius=R];
% define two helper coordinates, where the dashed lines should meet the circle
\path (O) +(theta:R) coordinate (a)
+(theta+90:R) coordinate (b);
% draw arc with solid part of equator
\draw (O) ++(R,0) arc[start angle=0,delta angle=-180,x radius=R,y radius=R/3];
% draw ard for dashed part of equator
\draw [dashed] (O) ++(R,0) arc[start angle=0,delta angle=180,x radius=R,y radius=R/3];
% draw the dashed lines to the center of the circle
\draw [dashed] (a) -- (O) -- (b);
% draw the two arrows that extend out of the circle
\draw [-latex] (O) ++(theta:R) -- ++(theta:0.75*R);
\draw [-latex] (O) ++(theta+90:R) -- ++(theta+90:0.75*R);
% draw the arced arrow with rho above
\draw [-latex] (O) ++(theta+80:R*1.2)
arc[start angle=theta+80,delta angle=-70,radius=R*1.2]
node[midway,above] {$\rho$};
% draw the right angle mark
\draw (O) ++(theta:R/10) -- ++(theta+90:R/10) -- ++(180+theta:R/10);
\end{tikzpicture}
\end{center}
\end{document}
舊答案
或者,您可以使用由庫定義的預定義pic
名為。標籤需要該庫。angle
angles
quotes
"$\rho$"
我建議用稍微不同的方式來製作該圖,但也將箭頭添加到您的程式碼中。雖然還沒有在那裡完成方形部分,但那裡的角度不是 90 度(在你的圖中)。嘗試\draw [rotate around={45:(2,2)}] (2,2) rectangle (2.5,2.5);
在之前添加\clip
來查看。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{angles,quotes,bending}
\begin{document}
\begin{center}
\begin{tikzpicture}[declare function={R=1.5cm;theta=45;}]
\draw (0,0) coordinate (O) circle[radius=R];
\draw (R,0) arc[start angle=0,delta angle=-180,x radius=R,y radius=R/3];
\draw [dashed] (R,0) arc[start angle=0,delta angle=180,x radius=R,y radius=R/3];
\draw [dashed] (180-theta:R) -- (O) -- (theta:R);
\draw [-latex] (theta:R) -- (theta:1.5*R) coordinate (a);
\draw [-latex] (180-theta:R) -- (180-theta:1.5*R) coordinate (b);
\draw pic [
shorten >=2mm,
shorten <=2mm,
draw,
latex-,
angle radius=1.2*R,
angle eccentricity=1.1,
"$\rho$"] {angle=a--O--b};
\draw (O) ++(theta:R/10) -- ++(180-theta:R/10) -- ++(180+theta:R/10);
\end{tikzpicture}
\begin{tikzpicture}[scale=.5]
\draw [dashed] (2,2) coordinate (O) -- (4, 4);
\draw [->] (4, 4) -- (5.5, 5.5) coordinate (a);
\draw [dashed] (2,2) -- (-.25, 3.678) ;
\draw [->] (-.25, 3.687) -- (-2, 5) coordinate (b);
\draw (2,2) circle (3cm);
\draw[dashed] (2,2) ellipse (3cm and 1cm);
\draw pic [
shorten >=2mm,
shorten <=2mm,
draw,
latex-,
angle radius=1.7cm,
angle eccentricity=1.1,
"$\rho$"] {angle=a--O--b};
\clip (-1.1,2) rectangle (5.1 cm, 0.9 cm);
\draw (2,2) ellipse (3cm and 1cm);
\end{tikzpicture}
\end{center}
\end{document}
答案2
PSTricks 解決方案:
\documentclass{article}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(-2.5,-2)(2.5,3.4)
\pscircle(0,0){2}
\psellipticarc(0,0)(2,1){180}{0}
{\psset{linestyle = dashed}
\psellipticarc(0,0)(2,1){0}{180}
\psline(!2 2 sqrt div neg 2 2 sqrt div)(0,0)%
(!2 2 sqrt div 2 2 sqrt div)}
\psline{->}(!2 2 sqrt div neg 2 2 sqrt div)(-2.5,2.5)
\psline{->}(!2 2 sqrt div 2 2 sqrt div)( 2.5,2.5)
\psline(-0.2,0.2)(0,0.4)(0.2,0.2)
\psarc{<-}(0,0){3}{50}{130}
\uput[90](0,3){$\rho$}
\end{pspicture}
\end{document}