如何在图表上标示“包括”和“排除”点?
\documentclass[paper=a4, fontsize=11pt]{scrartcl}
\usepackage{pgfplots, pgfplotstable}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[very thick, smooth,samples=200,domain=-2:0]{0};
\addplot[very thick, smooth,samples=200,domain=0:0.5]{2*x};
\addplot[very thick, smooth,samples=200,domain=0.5:1]{6-6*x};
\addplot[very thick, smooth,samples=200,domain=1:2]{0};
\end{axis}
\end{tikzpicture}
\end{document}
提前致谢!
答案1
您的意思是您想在不连续处的两侧使用不同的标记吗?
这是一种可行的(虽然有点乏味)方法;我不知道有没有更自动化的方法来实现这一点pgfplots
,但也许有一种......时间会证明一切。
\documentclass{article}
\usepackage{pgfplots}
\tikzset{
jumpdot/.style={mark=*,solid},
excl/.append style={jumpdot,fill=white},
incl/.append style={jumpdot,fill=black},
}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[very thick, smooth,samples=200,domain=-2:0]{0};
\addplot[very thick, smooth,samples=200,domain=0:0.5]{2*x};
\addplot[incl] coordinates {(.5,1)};
\addplot[very thick, smooth,samples=200,domain=0.5:1]{6-6*x};
\addplot[excl] coordinates {(.5,3)};
\addplot[very thick, smooth,samples=200,domain=1:2]{0};
\end{axis}
\end{tikzpicture}
\end{document}