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 ?
#4
I didn't explore source code of matplotlib in detail, but in general, computation of values where ytick labels will be shown is performed by a matplotlib.ticker instance. By default, it is ticker.AutoLocator:

from matplotlib.ticker import AutoLocator
aul = AutoLocator()
aul.tick_values(1, 3)
Output:
array([1. , 1.25, 1.5 , 1.75, 2. , 2.25, 2.5 , 2.75, 3. ])
from pylab import *
plt.plot([1,2,3])
plt.show() # yields a graph with ticks placed in above positions
This default behavior is made for convenience, and it could be easily overridden using axes.set_yticks etc. Note, there are minor and major ticks (we are talking about major one here), so underlying machinery is quite tricky.
Reply


Messages In This Thread
RE: How matplotlib automatically set x-axis and y-axis limits for bar graph ? - by scidam - Jul-04-2019, 08:23 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Setting the x-axis to a specific column in a dataframe devansing 0 2,031 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,459 Mar-03-2021, 08:26 AM
Last Post: atomxkai
  Bar Chart axis Blyzz 0 1,339 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,308 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,273 Sep-19-2019, 02:09 AM
Last Post: scidam
  Automatically plot each variable on the same graph for each "ID" AdWill97 0 2,100 Apr-15-2019, 09:29 AM
Last Post: AdWill97
  How to prevent tick labels overlapping with axis SriRajesh 2 23,903 May-12-2018, 06:13 PM
Last Post: SriRajesh
  Current time on x axis in matplolib Stumpy_L 2 4,290 Feb-07-2018, 02:07 PM
Last Post: Stumpy_L
  Automatically updated graph in jupyter notebook using qt5 capponero 0 4,070 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