pgfplots:中断图的线宽不均匀

pgfplots:中断图的线宽不均匀

我画了一张图,但红线的宽度似乎在各处都不一样。例如,在 [a,b] 之间,红线看起来更粗。

\documentclass{beamer}
\usetheme{CambridgeUS}

\usepackage{pgfplots}
\pgfplotsset{compat=1.7}

\begin{document}
\begin{frame}

    \begin{tikzpicture}
        \pgfplotsset{every axis plot/.style={line width=1pt}}
        \begin{axis}[x                 = 1cm,
                     y                 = 3cm,
                     axis x line       = bottom, 
                     axis y line       = center,
                     xmin              = -.5,
                     xmax              = 4,
                     ymin              = 0,
                     ymax              = 1,
                     enlarge x limits  = 0.05,
                     xlabel            = $y$, 
                     xlabel style      = {at={(axis description cs:1.05,0)}},
                     ylabel            = $p_X(y)$,
                     ylabel style      = {at={(axis description cs:-.1,1.05)}},
                     unbounded coords  = jump,
                     xtick             = {1,2.5},
                     ytick             = 0.5,
                     xticklabels       = {$a$,$b$},
                     yticklabels       = {$\frac{1}{b-a}$},
                     xticklabel style  = {anchor = base, yshift =-\baselineskip}]
         \addplot+[every mark/.append style = {mark size=1.5,fill=red}, mark indices = {3,4}, red] coordinates {(-.5,0)(1,0)(nan,nan)(1,.5)(2.5,.5)(nan,nan)(2.5,0)(4,0)};
        \end{axis}
    \end{tikzpicture}

\end{frame}

\end{document} 

答案1

轴线默认会剪切您的图,因此clip=false在您精妙的缩进代码中添加选项即可解决该问题。

在此处输入图片描述

相关内容