首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >模块matplotlib没有“Blues”成员

模块matplotlib没有“Blues”成员
EN

Stack Overflow用户
提问于 2019-06-02 22:54:18
回答 1查看 363关注 0票数 0

我设置了颜色'Blues‘,它可以成功地运行并显示无花果,但输出在这里"cmap=plt.cm.Blues“显示一个问题,不能保存无花果

代码语言:javascript
运行
复制
import matplotlib.pyplot as plt


x_values = list(range(1,1001))
y_values = [x**2 for x in x_values]


plt.scatter(x_values, y_values, c= y_values, cmap=plt.cm.Blues, edgecolor= 'none',  s=20)

#Set chart title and label axes
plt.title("Square Number" , fontsize= 15)
plt.xlabel("Value", fontsize = 15)
plt.ylabel("Square of Value", fontsize = 10)

#set the range for each axis
plt.axis([0, 1100, 0, 1100000])

#set size of tick labels
plt.tick_params(axis= 'both', which = 'major', labelsize = 8)

plt.show()
plt.savefig('squares_plot.png', bbox_inches= 'tight')
EN

回答 1

Stack Overflow用户

发布于 2020-06-03 20:49:21

原因是cmmatplotlib的一部分,而您只导入了matplotlib.pyplot

试试这个:

代码语言:javascript
运行
复制
import matplotlib as mpl
# ... your code goes here
plt.scatter(x_values, y_values, c= y_values, cmap=mpl.cm.Blues, edgecolor= 'none',  s=20)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56416144

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档