There is (unfortunately) no way to query the actual limits in the case you described above, but based on your last sentence, I suspect what you want is the "data extents" not the "automatic limits".
The only solution I can think of is to use 'tight' limits instead of manually set limits. The resulting automatically selected limits will be tightly cropped to the data extents.
xl = xlim
xl =
1 2
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Unfortunately, this technique doesn't allow you to set just the lower-limit to 'auto' or 'tight', you need to set both the lower and upper limits. If you need to work-around that issue, I can think of two solutions:
Option 1: Query then change one value of the limits.
You could set the limits to tight, then set just the upper limit to a new value to achieve the effect above. Just beware that doing so could slow down your code. Specifically: querying and the immediately setting the limits can lead to performance issues as described on this documentation page: Optimize Code for Getting and Setting Graphics Properties. xl = xlim
xl =
1 3
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Option 2: Add a "dummy" and invisible object at the desired upper limits.
You can add a "dummy" data point to the axes at the desired upper limits, and force the upper limits to your desired value.
xl = xlim
xl =
1 3
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>