Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make 0,0 on matplotlib graph on the bottom left corner? [duplicate]

I currently have a graph that looks like this using mathplotlib graph

However the margins between where the line actually starts and the edges of the graph are unnecessary, do you know how I can get rid of the margins so 0,0 starts at the corner?

For example, I want it to look like this enter image description here

like image 374
nimbyest Avatar asked Jun 06 '17 17:06

nimbyest


People also ask

How do you start a graph at 0 0 in Python?

To show (0,0) on matplotlib graph at the bottom left corner, we can use xlim() and ylim() methods.

How do you change increments on a graph in Matplotlib?

To change the range of X and Y axes, we can use xlim() and ylim() methods.

How do I fill in below a line in Matplotlib?

To fill the area under the curve, put x and y with ste="pre", using fill_between() method. Plot (x, y1) and (x, y2) lines using plot() method with drawstyle="steps" method. To display the figure, use show() method.

What is %Matplotlib inline?

You can use the magic function %matplotlib inline to enable the inline plotting, where the plots/graphs will be displayed just below the cell where your plotting commands are written. It provides interactivity with the backend in the frontends like the jupyter notebook.


1 Answers

plt.xlim([0, x_max])
plt.ylim([0, y_max])

You can easily get the values of (x_max, y_max) from your data.

like image 96
blue_note Avatar answered Oct 09 '22 03:10

blue_note