psline 与 tbar 末端的奇怪行为

psline 与 tbar 末端的奇怪行为

我使用 tbars 来显示条形图中的错误。但是,有些错误非常小。由于这些小错误,tbars 以奇怪的方式显示。它们从第一个坐标开始,并在第二个坐标上增长,具体取决于线宽和线的长度。是否可以防止线端超出线的限制?请参阅以下 MWE:

% !TeX program = xelatex
\documentclass[12pt]{article}
\usepackage{pstricks,pst-plot,pst-bar,pst-fill,multido}

\begin{document}
\begin{pspicture}(0,0)(3,3)%
\psaxes(0,0)(2,2)
\psset{tbarsize = 4pt}

% Show mentioned behavior with different linewidths and exchanging the start of the line. 
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2}{5}{\psline[linewidth=\dX]{|-|}(\nX,0.835)(\nX,0.825)
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2}{5}{\psline[linewidth=\dX]{|-|}(\nX,0.525)(\nX,0.535)}

% Show mentioned behavior with different linewidths and different line lengths
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2, \nY = 1.405 + 0.010}{10}{\psline[linewidth=1.2pt]{|-|}(\nX,1.4)(\nX,\nY)}
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2, \nY = 1.605 + 0.010}{10}{\psline{|-|}(\nX,1.6)(\nX,\nY)}
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2, \nY = 1.805 + 0.010}{10}{\psline[linewidth=0.4pt]{|-|}(\nX,1.8)(\nX,\nY)}
\end{pspicture}
\end{document}

答案1

使用\psline[...]{|*-|*}(...)

\documentclass[pstricks]{standalone}
\usepackage{multido,pst-plot}

\begin{document}
\begin{pspicture}(-0.75,-0.75)(3,3)%
\psaxes(0,0)(2,2)
\psset{tbarsize = 4pt}

% Show mentioned behavior with different linewidths and exchanging the start of the line. 
\psset{linecolor=red}
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2}{5}{\psline[linewidth=\dX]{|*-|*}(\nX,0.835)(\nX,0.825)}
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2}{5}{\psline[linewidth=\dX]{|*-|*}(\nX,0.525)(\nX,0.535)}

\psset{linecolor=blue}
% Show mentioned behavior with different linewidths and different line lengths
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2, \nY = 1.405 + 
0.010}{10}{\psline[linewidth=1.2pt]{|*-|*}(\nX,1.4)(\nX,\nY)}
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2, \nY = 1.605 + 
0.010}{10}{\psline{|*-|*}(\nX,1.6)(\nX,\nY)}
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2, \nY = 1.805 + 
0.010}{10}{\psline[linewidth=0.4pt]{|*-|*}(\nX,1.8)(\nX,\nY)}
\end{pspicture}
\begin{pspicture}(-0.75,-0.75)(3,3)%
\psaxes(0,0)(2,2)
\psset{tbarsize = 4pt}
% Show mentioned behavior with different linewidths and exchanging the start of the line. 
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2}{5}{\psline[linewidth=\dX]{|-|}(\nX,0.835)(\nX,0.825)}
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2}{5}{\psline[linewidth=\dX]{|-|}(\nX,0.525)(\nX,0.535)}

% Show mentioned behavior with different linewidths and different line lengths
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2, \nY = 1.405 + 
0.010}{10}{\psline[linewidth=1.2pt]{|-|}(\nX,1.4)(\nX,\nY)}
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2, \nY = 1.605 + 0.010}{10}{\psline{|-|}(\nX,1.6)(\nX,\nY)}
\multido{\dX = 0.1pt + 0.2pt, \nX=0.1+0.2, \nY = 1.805 + 
0.010}{10}{\psline[linewidth=0.4pt]{|-|}(\nX,1.8)(\nX,\nY)}

\end{pspicture}
\end{document}

在此处输入图片描述

相关内容