我正在尝试重新定义 x 轴的标签pst-plot
通过放置图表
\makeatletter
\def\ps@@@hlabel#1{\small(#1)}
\makeatother
在序言中(参见第 25 页顶部)手动的),但根本没有打印任何标签。
例子:
\documentclass{article}
\usepackage{pst-plot}
% Label redefinition. (NOT working)
\makeatletter
\def\ps@@@hlabel#1{\small(#1)}
\makeatother
% Makes things easier.
\def\afspil#1#2{%
% \rput(!2 #1 mul -0.3){\small{(#1)}} <-- (`manually' plotting of labels)
\psline[linecolor=red](!2 #1 mul 0)(!2 #1 mul #2)
\psline[linecolor=red](!2 #1 mul 0.2 sub #2)(!2 #1 mul 0.2 add #2)
}
\begin{document}
\begin{pspicture}
\psaxes[
labels=none,
ticks=y,
ticklinestyle=dotted,
tickwidth=0.5pt,
yticksize=0 12.9
]{->}(0,0)(-0.3,-0.3)(13.1,8.6)[Sang,0][Afspilninger,90]
\psaxes[
dy=1,
Dy=10,
labels=y,
ticks=y,
ylabelFactor=\cdot 10^3
](0,0)(-0.3,-0.3)(13.1,8.6)
\afspil{1}{6.4098}
\afspil{2}{5.0320}
\afspil{3}{7.5437}
\afspil{4}{6.3253}
\afspil{5}{0.5735}
\afspil{6}{6.9024}
\end{pspicture}
\end{document}
如何重新定义 x 轴上的标签?
答案1
有两件事:首先,您仅使用y
-labels 绘制两个轴,而您需要更改的宏是\pst@@@hlabel
。它在第 25 页的文本中是正确的,但在段落后面的示例中是错误的。以下内容有效:
\documentclass{article}
\usepackage{pst-plot}
% Label redefinition.
\makeatletter
\def\pst@@@hlabel#1{\small(#1)}
\makeatother
% Makes things easier.
\def\afspil#1#2{%
% \rput(!2 #1 mul -0.3){\small{(#1)}} <-- (`manually' plotting of labels)
\psline[linecolor=red](!2 #1 mul 0)(!2 #1 mul #2)
\psline[linecolor=red](!2 #1 mul 0.2 sub #2)(!2 #1 mul 0.2 add #2)
}
\begin{document}
\begin{pspicture}
\psaxes[
labels=none,
ticks=y,
ticklinestyle=dotted,
tickwidth=0.5pt,
yticksize=0 12.9
]{->}(0,0)(-0.3,-0.3)(13.1,8.6)[Sang,0][Afspilninger,90]
\psaxes[
dy=1,
Dy=10,
ylabelFactor=\cdot 10^3
](0,0)(-0.3,-0.3)(13.1,8.6)
\afspil{1}{6.4098}
\afspil{2}{5.0320}
\afspil{3}{7.5437}
\afspil{4}{6.3253}
\afspil{5}{0.5735}
\afspil{6}{6.9024}
\end{pspicture}
\end{document}
答案2
如果你只想更改标签数字的大小,则可以使用 keyval labelFontSize=\scriptstyle
。要使用此功能,你必须加载包pstricks-add
。
例子:
\documentclass{article}
\usepackage{pst-plot,pstricks-add}
\begin{document}
\psset{xunit=1.3cm,yunit=0.6cm,algebraic=true,dotstyle=*,dotsize=3pt 0,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25}
\begin{pspicture*}(-1,-4.3)(9,10)
\psgrid[subgriddiv=0,gridcolor=gray,gridwidth=0.4pt,griddots=0,gridlabels=0pt](-1,-4)(9,10)
\psaxes[labelFontSize=\scriptstyle,xAxis=true,yAxis=true,Dx=1,Dy=1,ticksize=-3pt 0,subticks=2]{->}(0,0)(0,-4)(9,10)
\psplot[plotpoints=200,linecolor=black,algebraic]{0}{9}{(3-3*x)*2.718^(2-x)}
\end{pspicture*}
\end{document}