TransWikia.com

How can I get rid of the white space in matplotlib?

Data Science Asked by Faisal on June 3, 2021

I am doing a course in edx. While plotting in python, there is always a blank space before the beginning of the plot. In StackExchange, I have found a solution, which is mentioning the axis limit. However, in maximum cases, the starting points of the plot is unknown. So, Is there any solution to this without manipulating the axis limits manually? A graph is attached herewith for making things more clear.

enter image description here

One Answer

This stackoverflow answer should solve your issue. You can use either plt.margins(x=0) or ax.margins(x=0) to remove all margins on the x-axis.

Answered by Oxbowerce on June 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP