It might be trivially easy to learn but this is a bit urgent for me. So if anyone has some sample codes in latex to share with or document easily explain how to obtain something like http://en.wikipedia.org/wiki/File:Discrete_probability_distribution_illustration.svg it would be great. Many thanks!
Asked
Active
Viewed 1,160 times
1 Answers
4
Given the urgency, there is a fast draft, without explanations. Feel free to ask.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzset{
open/.style = {circle, minimum size=2mm,draw, fill=white,inner sep=0pt},
closed/.style = {circle, minimum size=2mm, fill, inner sep=0pt},
}
\begin{tikzpicture}[thick]
\draw[blue] (0,0) -- +(4,0) node[pos=0,left] {\tt\color{black} 1};
\draw[blue] (0,-1) -- +(4,0) node[pos=0,left] {\tt\color{black} 0};
\draw[red] (0,-1) -- (.6,-1) node[open] {};
\draw[red] (.6,-.75) node[closed] {} -- (1.6,-.75) node[open] {};
\draw[red] (1.6,-.4) node[closed] {} -- (3,-.4) node[open] {};
\draw[red] (3,0) node[closed] {} -- (4,0);
\end{tikzpicture}
\begin{tikzpicture}[thick]
\draw[blue] (0,0) -- +(4,0) node[pos=0,left] {\tt\color{black} 1};
\draw[blue] (0,-1) -- +(4,0) node[pos=0,left] {\tt\color{black} 0};
\draw[red] (0,-1) -- (1,-1) to[out=0,in=180] (3,0) -- (4,0);
\end{tikzpicture}
\begin{tikzpicture}[thick]
\draw[blue] (0,0) -- +(4,0) node[pos=0,left] {\tt\color{black} 1};
\draw[blue] (0,-1) -- +(4,0) node[pos=0,left] {\tt\color{black} 0};
\draw[red] (0,-1) -- (.3,-1) to[out=0, in=190] (1,-.9) node[open] {};
\draw[red] (1, -.6) node[closed] {} to[out=10,in=180] (3,0) -- (4,0);
\end{tikzpicture}
\end{document}
Result:

JLDiaz
- 55,732
*andostyle tikz arrows so that they are centered at the end of line, What is the clearest way to graph a piecewise function?. – Claudio Fiandrino Aug 29 '13 at 18:17