目标是将\circ
表示角度(以度为单位)的水平标签附加到每个水平标签上。如何操作?我在pst-plot
手册中找不到解决方案。
\documentclass[pstricks,border=12pt,12pt,dvipsnames]{standalone}
\usepackage{pst-plot}
\usepackage[nomessages]{fp}
\FPeval\dx{pi/4}
\FPeval\Dx{round(180/pi*dx:0)}
\FPeval\dy{1}
\FPeval\XMin{0-pi/3}
\FPeval\XMax{2*pi}
\FPeval\YMin{0-3}
\FPeval\YMax{3}
\FPeval\L{XMin-dx/2}
\FPeval\R{XMax+dx/2}
\FPeval\B{YMin-dy/2}
\FPeval\T{YMax+dy/2}
\psset
{
algebraic,
xunit=15mm,
}
\begin{document}
\begin{pspicture}(\L,\B)(\R,\T)
\psaxes[dx=\dx,Dx=\Dx]{->}(0,0)(\L,\B)(\R,\T)
\psplot[linecolor=blue]{\XMin}{\XMax}{2*sin(x)}
\end{pspicture}
\end{document}
答案1
\psaxes[dx=\dx,Dx=\Dx,xlabelFactor={}^\circ]{->}(0,0)(\L,\B)(\R,\T)
答案2
只是为了好玩pgfplots
:
\documentclass[border=12pt,12pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x={1.5cm/60},
domain=-60:360,
samples=100,
axis x line=middle,
axis y line=center,
xmin=-70, xmax=370,
xtick={-45,45,90,...,360},
xticklabel={$\pgfmathprintnumber\tick^{\circ}$},
ymin=-3.5, ymax=3.5,
ytick={-3,-2,-1,1,2,3},
]
\addplot[blue,mark=none] {2*sin x};
\end{axis}
\end{tikzpicture}
\end{document}