Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
879 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 Reply

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...