Skip to content
Plotly templates

Math — Plot: Piecewise Function

f(x) = x for x < 0 and x^2 for x >= 0.

Template previewPlotly
Rendering…

Make it your own.

{
  "data": [
    {"type":"scatter","mode":"lines+markers","name":"f(x)","line":{"color":"#0891b2","width":3},
     "x":[-3,-2,-1,0,1,2,3],"y":[-3,-2,-1,0,1,4,9]}
  ],
  "layout": {"title":"Piecewise function","xaxis":{"title":"x"},"yaxis":{"title":"f(x)"}}
}