Python 在matplotlib'中显示非常窄的矩形的颜色;s条形图
我试图在matplotlib中绘制x轴范围非常宽的数据。我有两组数据,我想通过两种颜色来区分。但是,标准条形图中使用的矩形非常窄,以至于无法显示颜色。以下是我使用的代码:Python 在matplotlib'中显示非常窄的矩形的颜色;s条形图,python,matplotlib,Python,Matplotlib,我试图在matplotlib中绘制x轴范围非常宽的数据。我有两组数据,我想通过两种颜色来区分。但是,标准条形图中使用的矩形非常窄,以至于无法显示颜色。以下是我使用的代码: import matplotlib.pyplot as plt fig=plt.figure() ax1=fig.add_subplot(111) ax1.bar(plotreal,plotabundance,color='#330000') #first data (x,y,color) ax1.bar(xlist,ylis
import matplotlib.pyplot as plt
fig=plt.figure()
ax1=fig.add_subplot(111)
ax1.bar(plotreal,plotabundance,color='#330000') #first data (x,y,color)
ax1.bar(xlist,ylist,color='#9999FF') #second set of data (x,y,color)
ax1.set_xlabel() #some axis labeling
ax1.set_ylabel() #some axis labeling
ax1.set_title() #some title labeling
plt.savefig('chart of '+str(counter)+'.png') #some more parameters
第二组中的数据可能与第一组中的数据重叠(具有相同的点),我希望在这种情况下,它的颜色能够显示出来。我感兴趣的是保持这种显示格式,其中每个点都显示为直线/矩形,只需为直线/矩形添加颜色即可
尽管我尝试对两个数据集进行对比,但仍然无法区分本例中的第二个数据集仅包含4个坐标,而第一个数据集包含其余坐标
(如果有人喜欢古玩,这是质谱仪的输出数据)
是否有其他我缺少的图形类型或参数可用于解决此颜色问题?提前感谢。边缘颜色由不同的参数设置(默认值=黑色)。您的条太小,无法看到填充颜色,因此它看起来是黑色的,因为边缘保持相同的大小 要修复此问题,请添加edgecolor=…:
import matplotlib.pyplot as plt
fig=plt.figure()
ax1=fig.add_subplot(111)
ax1.bar(plotreal,plotabundance,color='#330000',edgecolor='#330000') #first data (x,y,color,edgecolor)
ax1.bar(xlist,ylist,color='#9999FF',edgecolor='#9999FF') #second set of data (x,y,color,edgecolor)
ax1.set_xlabel() #some axis labeling
ax1.set_ylabel() #some axis labeling
ax1.set_title() #some title labeling
plt.savefig('chart of '+str(counter)+'.png') #some more parameters
您是否尝试过设置
edgecolor='none'
?你也可以增加横条的宽度。不,我没有,但是可以!使用无边颜色并将宽度设置为20,可以制作足够厚的可分辨矩形