# Drawing Piecewise Graphs in LaTeX [duplicate]

I have been using LaTeX forever, but strangely just realized I've never had to plot a graph in it. The graph is seen here:

and the equations are here

I want to use

\usepackage{pgfplots}


However I am open to using other packages if you recommend any?

Thanks

• Welcome! The subject of piecewise graphs has been asked and answered many times on this site – cmhughes Mar 11 '18 at 20:45
• – Stefan Pinnow Mar 11 '18 at 20:46

as starting point:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}
\begin{tikzpicture}
\begin{axis}[samples=60]
%
\end{axis}
\end{tikzpicture}
\end{document}


where deg make conversion of argument x from radians to degrees (trigonometric functions are defined for degrees).

• or you can write x r it will understand radians context with that, or change the trig format – percusse Mar 11 '18 at 20:56
• @percusse, i simply forgot on this option :-(. thank you very much to remind me :-). but now i make short text, and receive error. i should repeat my test more carefully. – Zarko Mar 11 '18 at 20:59

Same output as Zarko's nice answer, but really piecewise functions with ifthenelse.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}
\begin{tikzpicture}
\begin{axis}[samples=60]