Add a vertical slider with matplotlib
Matplotlib not only allows static graphs, but we can also prepare plots that can be modified interactively. For this, we can use the Sliders widget present in the widgets submodule to control the visual properties of your plot.
The only difference between horizontal and vertical Sliders being the presence of an additional parameter ‘orientation’ which is by default set to ‘horizontal’.
amp_slider = Slider(
orientation=”vertical” # Update it to “horizontal” if you need a horizontal graph
Here we will use the Slider widget to create a plot of a function with a scroll bar that can be used to modify the plot. In this example, two sliders (one vertical and one horizontal )are being used to choose the amplitude and frequencies of a sine wave. We can control many continuously-varying properties of our plot in this way.
Continuously-varying properties like Amplitude and Frequency of a Sine Wve could be controlled using Sliders effectively :
As we can observe from example images the plot can be modified during runtime by using the Sliders submodule present in Matplotlib.
Therefore, the only difference between the horizontal and vertical Sliders is the presence of an additional parameter ‘orientation’ which is by default set to ‘horizontal’ and there is no difference in implementation of the orientation you want.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course