How to Set Axis Limits bokeh?
In this article, we will be learning about how to set axis limits to a plot in bokeh. When we are plotting a graph with a set of values, then X-limits and Y-limits for the points are automatically created. But bokeh allows us to set those axis limits according to our choice.
So, at first, we need to know that in order to set Axis limits to both X and Y axis, we need to import a package from our bokeh.models module which is known as range1d. Range1d enables us to set axis limits to the plot of our choice.
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
We can either use google colab or we can use any text editor in our local device to do the above implementation. In order to use a text-editor on our local device, we need to open the command prompt at first and write the following code.
pip install bokeh
After installation, now we are ready to proceed to the main implementation.
In the code below, we are creating an empty plot with the limits of X-axis and Y-Axis according to our choice.
As we can clearly see from the code, that we have set X-Axis limits from 0-10 and Y-Axis Limits from 5-15. The thing has been implemented in the graph shown above.
In the second example, we are setting the X and Y Axis limits of our own, and then we are pointing a set of points in that range in the graph. The below code shows the above implementation.
Since this is a customized axis made by us, the size of the graph will be totally dependent on the axis limits. For example: if the axis limits for both the axis is larger, then the graph plotted above will be smaller than the one shown now.