Python Forum
How matplotlib automatically set x-axis and y-axis limits for bar graph ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How matplotlib automatically set x-axis and y-axis limits for bar graph ?
#1
Hi,

I am confused in math/logic behind automatically by-default setting of x-axis and y-axis limits in bar graph ? Here i am sharing some examples

1.
import matplotlib.pyplot as plt
x = [1,2,3,4,5]
y = [1000, 1002, 1001, 1003, 1005]
plt.bar(x,y) 
plt.show()
In this bar graph, X axis limits are 0,1,2,3,4,5 and Y axis limits are 0,200,400,600,800,1000. How is happened??

2.
import matplotlib.pyplot as plt
x=[20,30,90,70, 50, 60, 80, 70]
y=[3,2,5,10, 3, 9, 7, 6]
plt.bar(x,y)
plt.show()
In this bar graph, X axis limits are 0,20,30,40,50,60,70,80,90 and Y axis limits are 0,2,4,6,8,10. How is happened??
Reply


Messages In This Thread
How matplotlib automatically set x-axis and y-axis limits for bar graph ? - by ift38375 - Jul-03-2019, 11:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Setting the x-axis to a specific column in a dataframe devansing 0 2,042 May-23-2021, 12:11 AM
Last Post: devansing
  IndexError: index 0 is out of bounds for axis 0 with size 0 atomxkai 2 5,510 Mar-03-2021, 08:26 AM
Last Post: atomxkai
  Bar Chart axis Blyzz 0 1,345 Dec-01-2020, 02:36 AM
Last Post: Blyzz
  IndexError: index 0 is out of bounds for axis 0 with size 0 tmhsa 0 5,329 Apr-24-2020, 10:00 AM
Last Post: tmhsa
  how to get x values based on y-axis values from curvefit function python_newbie09 1 3,289 Sep-19-2019, 02:09 AM
Last Post: scidam
  Automatically plot each variable on the same graph for each "ID" AdWill97 0 2,121 Apr-15-2019, 09:29 AM
Last Post: AdWill97
  How to prevent tick labels overlapping with axis SriRajesh 2 23,932 May-12-2018, 06:13 PM
Last Post: SriRajesh
  Current time on x axis in matplolib Stumpy_L 2 4,331 Feb-07-2018, 02:07 PM
Last Post: Stumpy_L
  Automatically updated graph in jupyter notebook using qt5 capponero 0 4,088 May-16-2017, 03:08 PM
Last Post: capponero

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020