Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
903 views
in Technique[技术] by (71.8m points)

python - 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.xlim(xlim)
plt.show()

For some reason, I get the error, that the list object is not callable. I am well aware, that the question was asked before here: list not callable for plot, but unfortunately, the solution does not work for me. Is there another way?

Thanks and happy coding

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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])

see resulting plot

(*Using matplotlib==3.2.2, and seaborn==0.10.1)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...