Matplotlib Plt.xlim([x_min,x_max]), List Object Not Callable
I want to plot a scatterplot, but set the x-label limits. axScatter = plt.subplot(111) axScatter.scatter(x=mean_var_r['Variance'],y=mean_var_r['Mean']) xlim = [-0.003, 0.003] plt.x
Solution 1:
With some help from seaborn, set_xlim
and set_ylim
properties work quite intuitively:
import seaborn as sns
ax = sns.lineplot(x=range(0,100),
y=range(0,100))
ax.set_xlim([50, 100])
ax.set_ylim([50, 100])
(*Using matplotlib==3.2.2, and seaborn==0.10.1)
Solution 2:
It appears that the API has changed. See this page. The function no longer accepts a list; the function accepts a tuple.
Try this:
axScatter = plt.subplot(111)
axScatter.scatter(x=mean_var_r["Variance"],y=mean_var_r["Mean"])
xlim = (-0.003, 0.003)
plt.xlim(xlim)
plt.show()
Post a Comment for "Matplotlib Plt.xlim([x_min,x_max]), List Object Not Callable"