What is the difference between set_xlim and set_xbound?

The bound can changes automatically, if you later plot something that is not within the bound. In contrast, limits are fixed and do not change automatically. import pylab as p t = p.arange(0.0, 2.0, 0.01) s = p.sin(2*p.pi*t) ax=p.subplot(111) ax.plot(t, s, color=”r”,linewidth=1.0) ax.set_ylim(-1,1) ax.plot(t, s+1, color=”g”,linewidth=1.0, label=”Graph2″) p.show() ax=p.subplot(111) ax.plot(t, s, color=”r”,linewidth=1.0) ax.set_ybound(-1,1) ax.plot(t, s+1, … Read more

Setting the same axis limits for all subplots

Set the xlim and ylim properties on the Artist object by matplotlib.pyplot.setp() https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.pyplot.setp.html # Importing matplotlib.pyplot package. import matplotlib.pyplot as plt # Assigning ‘fig’, ‘ax’ variables. fig, ax = plt.subplots(2, 2) # Defining custom ‘xlim’ and ‘ylim’ values. custom_xlim = (0, 100) custom_ylim = (-100, 100) # Setting the values for all axes. plt.setp(ax, xlim=custom_xlim, … Read more

Plotting time on the independent axis

Update: This answer is outdated since matplotlib version 3.5. The plot function now handles datetime data directly. See https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.pyplot.plot_date.html The use of plot_date is discouraged. This method exists for historic reasons and may be deprecated in the future. datetime-like data should directly be plotted using plot. If you need to plot plain numeric data as … Read more