tell exact difference between xlim() and xticks() function - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: tell exact difference between xlim() and xticks() function (/thread-19696.html) |
tell exact difference between xlim() and xticks() function - ift38375 - Jul-11-2019 I am confused in xlim() and xticks() function of Matplotlib.pyplot. are both same or different ? Please explain with simple graph example.. RE: tell exact difference between xlim() and xticks() function - scidam - Jul-11-2019 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
ax.get_xticks() # returns where ticks be located. plt.xticks() returns xticks for the current axes 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)
plt.xticks()
ax.get_xticks()
plt.xlim()
RE: tell exact difference between xlim() and xticks() function - ift38375 - Jul-11-2019 (Jul-11-2019, 02:10 AM)scidam Wrote: They are different. The first ( can we use values with Negative X-axis/Y-axis ? RE: tell exact difference between xlim() and xticks() function - scidam - Jul-12-2019 (Jul-11-2019, 03:27 PM)ift38375 Wrote: can we use values with Negative X-axis/Y-axis ?Yes, you can use negative values in these functions. |