0

I am trying to create a third slider to control my plot.

fig, ax = plt.subplots()
plt.subplots_adjust(left=0.25, bottom=0.25)
l, = plt.plot(u,v, lw=1, color='red')
plt.axis([-20, 20, -20,20])


amp_slider_ax  = fig.add_axes([0.25, 0.15, 0.65, 0.03], axisbg=axis_color)
samp = Slider(amp_slider_ax, 'Ey', 1, 10.0, valinit=a0)

freq_slider_ax = fig.add_axes([0.25, 0.1, 0.65, 0.03], axisbg=axis_color)
sfreq = Slider(freq_slider_ax, 'gamma (Ex/Ey)', 0.01, 1.3, valinit=f0)

#new slider
fbz_slider_ax = fig.add_axes([3, 7, 0.65, 0.03], axisbg=axis_color)
sbz = Slider(fbz_slider_ax, 'Bz', 0.01, 1.3, valinit=b0)

I don't see why my third slider is not being initialized. Can someone provide an example with 3 sliders, please. When I call the slider object, I do not get any errors either.

peasqueeze
  • 51
  • 8
  • There's already an example with [two sliders](http://matplotlib.org/users/screenshots.html#slider-demo), and I added some notes to it [here](http://stackoverflow.com/questions/43381449/how-to-make-two-sliders-in-matplotlib/43382206#43382206). – berna1111 Apr 25 '17 at 22:51

1 Answers1

1

In the line fig.add_axes([3, 7, 0.65, 0.03]) you are adding an axes at coordinates (3,7). The point (3,7) does not lie inside the figure, as the figure goes from 0 to 1 in both directions.

The solution is of course to add the axes somewhere inside the figure.

ImportanceOfBeingErnest
  • 251,038
  • 37
  • 461
  • 518