我想创建一个坐标位置,其中\psgrid
和\psaxes
。我使用 的标签\psaxes
并抑制 的标签\psgrid
。我的问题是负号(用于负标签)往往会被 的线条遮挡\psgrid
。这是我的起始代码:
\documentclass{article}
\usepackage{pstricks-add}
\begin{document}
\begin{center}
\psset{xunit=1cm,yunit=1cm}
\begin{pspicture}(-7.5,-5.5)(7.5,5.5)
\psgrid[gridwidth=0.2pt, gridlabels=0pt, subgriddiv=2](-7,-5)(7,5)
\psaxes[labelFontSize=\scriptstyle, ticks=none,
linewidth=0.8pt]{->}(0,0)(-7.5,-5.5)(7.5,5.5) [$x$,-120]
[$y$,-40]
\end{pspicture}
\end{center}
我希望将标签显示在带有纯白色(或任何其他颜色)背景的框中,以使标签更易读。(我想实现\ncput*
与节点连接器类似的效果。)
谢谢
编辑:
在查看了@Bernard 的解决方案及其使用之后\psframebox*
,我进行了一些调整\psvlabel
并找到了一个不需要我输入单独标签的解决方案。
\documentclass{article}
\usepackage{pstricks-add}
\begin{document}
\begin{center}
\psset{xunit=1cm,yunit=1cm}
\renewcommand{\psvlabel}[1]{\psframebox*{\scriptsize $#1$}}
\renewcommand{\pshlabel}[1]{\psframebox*[framesep=2pt]{$#1$}}
\begin{pspicture}(-7.5,-5.5)(7.5,5.5)
\psgrid[gridwidth=0.2pt, gridlabels=0pt, subgriddiv=2](-7,-5)(7,5)
\psaxes[labelFontSize=\scriptstyle, ticks=none,
linewidth=0.8pt]{->}(0,0)(-7.5,-5.5)(7.5,5.5) [$x$,-120]
[$y$,-40]
\end{pspicture}
\end{center}
\pshlabel
但这引发了和命令的意外(错误?)行为\psvlabel
。您会注意到第二个标签命令中没有\scriptsize
,因为当我将其放入时,相应的标签会进一步缩小(即脚本大小相对于脚本大小)。
答案1
使用ylabelOffset
密钥:
\documentclass{article}
\usepackage{pstricks-add}
\usepackage{auto-pst-pdf}
\begin{document}
\begin{center}
\psset{xunit=1cm,yunit=1cm}
\begin{pspicture}(-7.5,-5.5)(7.5,5.5)
\psgrid[gridwidth=0.2pt, gridlabels=0pt, subgriddiv=2](-7,-5)(7,5)
\psaxes[labelFontSize=\scriptstyle, ticks=none, ylabelOffset=0.08, linewidth=0.8pt]{->}(0,0)(-7.5,-5.5)(7.5,5.5) [$x$,-120]
[$y$,-40]
\end{pspicture}
\end{center}
\end{document}
另一种解决方案是\psframebox*
:
\documentclass[x11names]{article}
\usepackage{pstricks-add}
\usepackage{auto-pst-pdf}
\newcommand\mylabel[1]{\psframebox*[framesep=1pt]{\scriptstyle#1}}
\begin{document}
\begin{center}
\psset{xunit=1cm,yunit=1cm}
\begin{pspicture}(-7.5,-5.5)(7.5,5.5)
\psgrid[gridwidth=0.4pt, subgridwidth=0.2pt, gridlabels=0pt, subgriddiv=2, gridcolor=SteelBlue4, subgridcolor =LightSteelBlue3](-7,-5)(7,5)
\psaxes[labelFontSize=\scriptstyle, ticks=none, labels=x]{->}(0,0)(-7.5,-5.5)(7.5,5.5) [$x$,-120]
[$y$,-40]
\psset{ticks=none, linewidth=0pt, linestyle=none}
\psaxes[yLabels = {,\mylabel{1},\mylabel{2},\mylabel{3},\mylabel{4},\mylabel{5}}]{-}(0,5.5)
\psaxes[yLabels={\mylabel{-5},\mylabel{-4}, \mylabel{-3}, \mylabel{-2}, \mylabel{-1}}]{-}(0,-5)(0,-5.5) (0,0)
\end{pspicture}
\end{center}
\end{document}
答案2
\documentclass{article}
\usepackage{pstricks-add}
\begin{document}
\psset{psgrid,gridcoor={(-7,-5)(7,5)},
gridpara={gridlabels=0pt,gridcolor=red!30,
subgridcolor=green!30,
subgridwidth=0.5\pslinewidth,
subgriddiv=2,labelFontSize=\scriptstyle}%
}
\begin{psgraph}{->}(0,0)(-7.5,-5.5)(7.5,5.5){\linewidth}{0.7\linewidth}
\uput[0](7.5,0){$x$}\uput[90](0,5.5){$y$}
\end{psgraph}
\end{document}