0

I am trying to change the limits of a Slider Widget in runtime, in the following code:

def draw(self):           
    self.fig, ax = plt.subplots()
    plt.subplots_adjust(left=0.25, bottom=0.40)
    self.Smile.getVolLimSmile(self.Smile.strike)
    vols = pd.DataFrame(self.Smile.smile,index = self.Smile.strike)       
    self.axes = plt.gca()
    self.axes.plot(self.Smile.strike, vols*100.) ####
    axatmvol = plt.axes([0.25, 0.30, 0.65, 0.03], axisbg=axcolor)
    self.satmvol = Slider(axatmvol, 'atmvol', 0.1, 50, valinit=self.atmvol)

I see that the Slider object gives access to the max and min value (originally set at 0.1 and 50 in the example) via the valmin and valmax properties, however I am not able to change them in runtime.

Is there a way I can change the range using variables?

mspadaccino
  • 382
  • 2
  • 5
  • 17
  • What do you mean 'unable to change them'? They are just attributes so you can reach in and touch them. I suspect you are noting that the limits are not changing. A nice PR into mpl would make `valmin` / `valmax` properties that also change the xlim of the axes, but you can also do that from the outside. – tacaswell Apr 08 '16 at 19:28
  • Yes, i mean that the slider does not refresh its limits if i change those attributes. Could you explain further on your suggestion? What do you meean by "PR into mpl"? – mspadaccino Apr 08 '16 at 21:45
  • PR -> 'pull request'. – tacaswell Apr 11 '16 at 14:24

0 Answers0