# How to vectorize/plot a function?

**URL:** <https://community.plotly.com/t/how-to-vectorize-plot-a-function/3631>\
**Category:** 📊 Plotly Python\
**Created:** [March 13, 2017, 8:27pm UTC](https://community.plotly.com/t/how-to-vectorize-plot-a-function/3631 "2017-03-13T20:27:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vp13](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@vp13](https://community.plotly.com/u/vp13)\
**Post date:** [March 13, 2017, 8:27pm UTC](https://community.plotly.com/t/how-to-vectorize-plot-a-function/3631/1 "2017-03-13T20:27:28Z")

</div>

For example, for a fixed axis, adding some interactivity so that the user can set x between 0 to 1000 for the below piece-wise function:

def fun1(x):  
if(x\<=100):  
return x  
elif(100\<x\<=200):  
return x  
elif(200\<x\<=500):  
return 50+((x-250)\*0.5)  
elif(x\>500):  
return 350+(x-500)

Is this possible in Plotly?
