They are different. The first (

`plt.xlim()`

) returns range for x-axis values of the current axes-instance,

the second returns array of xtick labels (where labels will be placed) within the interval returned by

`xlim`

.

Look at the following example:

import matplotlib.pyplot as plt
ax = plt.gca() # returns current axes (creates if needed)
ax.get_xlim() # now this is equivalent to plt.xlim(), plt.xlim() returns xlims for the current axes

Output:

(0.0, 1.0)

ax.get_xticks() # returns where ticks be located. plt.xticks() returns xticks for the current axes

Output:

array([0. , 0.2, 0.4, 0.6, 0.8, 1. ])

Lets change xlims, e.g.

ax.set_xlim(5, 9) # the same as plt.xlim(5, 9) (we are still working with the current axes)

Output:

(5, 9)

plt.xticks()

Output:

(array([5. , 5.5, 6. , 6.5, 7. , 7.5, 8. , 8.5, 9. ]),
<a list of 9 Text xticklabel objects>)

ax.get_xticks()

Output:

array([5. , 5.5, 6. , 6.5, 7. , 7.5, 8. , 8.5, 9. ])

plt.xlim()

Output:

(5.0, 9.0)