[Tex/LaTex] Simple Characteristic Function or Step Function in pgfplots


How would I go about creating a simple characteristic function plot such as this in pgfplots? It is not necessary for my Latex processor to generate the plot based on a function, manually drawing the coordinates and lines will suffice. Is pgfplots an appropriate tool for the job?

characteristic function plots

Best Answer

Here's a simple solution using the pgfplots package


% arara: pdflatex
% !arara: indent: {overwrite: yes}

\pgfplotsset{every axis/.append style={
    axis x line=middle,    % put the x axis in the middle
    axis y line=middle,    % put the y axis in the middle
    axis line style={<->}, % arrows on the axis
    xlabel={$x$},          % default put x on x-axis
    ylabel={$y$},          % default put y on y-axis
    cmhplot/.style={color=red,mark=none,line width=1pt,<->},
    soldot/.style={color=red,only marks,mark=*},
    holdot/.style={color=red,fill=white,only marks,mark=*},



For reference, here's a solution using pstricks

% arara: latex
% arara: dvips
% arara: ps2pdf




Related Question