我想通过仅显示轴的有意义的部分来强调图中的某些特征,例如假设我有一个非常类似的图:
是否可以仅在两个指定点之间绘制 y 轴?与我下面拼凑起来的类似。
\begin{tikzpicture}
\begin{axis}[%
axis x line=bottom,
axis y line=left,
xmin=0,
ymin=0
]%
\addplot coordinates {
(0,0.6)
(0.1,0.3)
(1,1)
};
% Axis
\draw[thick] (axis cs:0,0.3) -- (axis cs:0,0.6);
% "Ticks"
\draw (axis cs:0.01,0.3) -- (axis cs:0,0.3);
\draw (axis cs:0.01,0.6) -- (axis cs:0,0.6);
\end{axis}
\end{tikzpicture}
答案1
您可以采用以下方法如何在绘图中添加零线?
\documentclass[border=1mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
axis x line=bottom,
axis y line*=left,
y axis line style={draw opacity=0},
xmin=-0.05,
ymin=0,
after end axis/.code={
\draw ({rel axis cs:0,0}|-{axis cs:0,0.3}) --
({rel axis cs:0,0}|-{axis cs:0,0.6});
}
]%
\addplot coordinates {
(0,0.6)
(0.1,0.3)
(1,1)
};
\end{axis}
\end{tikzpicture}
\end{document}