Legacy – Basic Chart Defining Axis Limit Workout
- 01:49
Workout demonstrating how to use the axis limits in Python
Glossary
Axis Limits Chart Option MatplotlibTranscript
When we make a plot using matplotlib, we may feel like defining the x and y limits. So how do we do that? Well, to start off with, let us just first import the matplotlib library.
Now let's create a simple plot with varying x and y values 1, 2, 3, 4, 5 and 1, 4, 8, 16. And we run it. Oh, there's an error. What is it? Well, we said that there were five values for the x, but we only give four values for the y. So that's the error, what we have to do is we just need to give an extra value 35 and running. Perfect, the plots look great. What Python does is that it automatically defines the access limits, but we can do it manually, we can just say that plt . axis and we can define that the x axis goes from zero and six. And we can say that the y axis goes from zero and say 40 and run it perfect. So you can see that there's an extra word Python that started to go from one and five. But once we define that the x value is going from zero and six. It has changed the limits for x and also y like redefined simple