当我运行一个 pgfplots 示例但使用 y 对数刻度时,我遇到了“填充”问题。这是 MWE
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[ymin=0,ymax=1,enlargelimits=false]
\addplot
[const plot,fill=blue,draw=black]
coordinates
{(0,0.1) (0.1,0.15) (0.2,0.5) (0.3,0.62)
(0.4,0.56) (0.5,0.58) (0.6,0.65) (0.7,0.6)
(0.8,0.58) (0.9,0.55) (1,0.52)}
\closedcycle;
\end{semilogyaxis}
\end{tikzpicture}
\end{document}
输出结果如下
我还尝试改变 y 的最小值,因为 0.0 的对数未定义,但这没有帮助。
答案1
您可以使用 将对数图的原点设置为始终位于图的底部边缘log origin y=infty
。这将影响 绘制的路径\closedcycle
,并定义绘图样式(如ybar
和)的起始ycomb
位置。默认情况下,原点设置为log origin y=0
。
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[
ymin=0.05,
ymax=1,
log origin=infty,
enlargelimits=false
]
\addplot
[const plot,fill=blue,draw=black]
coordinates
{(0,0.1) (0.1,0.15) (0.2,0.5) (0.3,0.62)
(0.4,0.56) (0.5,0.58) (0.6,0.65) (0.7,0.6)
(0.8,0.58) (0.9,0.55) (1,0.52)}
\closedcycle;
\end{semilogyaxis}
\end{tikzpicture}
\end{document}