I'm trying to plot my data using matplot lib. I have 3 separetes sets of data I want to plot in 3 subplots (I'm using this is my guidence):
plt.figure()
fig, axs = plt.subplots(nrows=3, ncols = 1, sharex=False)
ax1 = axs[0]
ax1.errorbar(X,Y,Err,fmt='o')
ax1.set_xscale('log')
ax1.set_yscale('log')
ax1.set_title('epsilon=1.5, kappa = 2')
plt.show()
However I get the x range from 1 (or 0, I'm not sure) to 100 and I want to reduce it. I tried this, by adding using:
ax1.xlim(0.5,13.5)
But I get an error:
AttributeError: 'AxesSubplot' object has no attribute 'xlim'
How can I change the range then?
The subplot() Function The layout is organized in rows and columns, which are represented by the first and second argument. The third argument represents the index of the current plot. plt.subplot(1, 2, 1) #the figure has 1 row, 2 columns, and this plot is the first plot.
errorevery: This parameter is also an optional parameter. They contain integer values which is used to draws error bars on a subset of the data.
ecolor: This parameter is an optional parameter. And it is the color of the errorbar lines with default value NONE. elinewidth: This parameter is also an optional parameter.
You might want to use Axes.axis(*v, **kwargs)
:
ax1.axis(xmin=0.5,xmax=13.5)
From the documentation:
Set/Get the axis properties
If len(*v)==0, you can pass in xmin, xmax, ymin, ymax as kwargs selectively to alter just those limits without changing the others.
The corresponding method of axis object is set_xlim(xmin,xmax).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With