热线电话:13121318867

登录
2020-08-18 阅读量: 1709
用matplotlib画柱形图和折线图的时候如何设定颜色?

import matplotlib as mpl

import matplotlib.pyplot as plt



fig,ax1=plt.subplots()

ax1.bar(["a","b","c"],[1,2,3],color='r')

#画柱形图的时候可以通过color参数设定颜色,"r"是红色的简称

ax1.bar(["a","b","c"],[0.5,1,1.5],color='b')

#"b"是蓝色的简称

#还可以这样设定,用四个数字指定,四个数字分别是,r饱和度,g饱和度,b饱和度,透明度

ax1.bar(["a","b","c"],[0.4,0.8,1],color=(1,0.5,0.5,0.8))

#如何想要配色好看,则需要一些美学知识。



#折线图颜色设定是一样的

ax1.plot(["a","b","c"],[1,2,3],color=(0,0,0,1),linewidth=10)

image.png






Other Parameters

----------------

color : scalar or array-like, optional

The colors of the bar faces.


21.1844
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子