python中matplotlib条形图数值大的在最底层显示_如何在matplotlib中设置条形图的大小...

我已经成功地用matplotlib绘制了聚集条形图,但我面临的问题是,有些图形与其他图形相比太小了,当用matplotlib绘制时,它们看起来根本不存在。有没有可能改变y轴,或者有什么方法可以让更小的条形图看起来更清晰?在

这是我的可视化代码。在# Setting the positions and width for the bars

pos = list(range(len(df3['Air'])))

width = 0.25

# Plotting the bars

fig, ax = plt.subplots(figsize=(10,5))

# Create a bar with pre_score data,

# in position pos,

plt.bar(pos,

#using df['pre_score'] data,

df3['Air'],

# of width

width,

# with alpha 0.5

alpha=0.5,

# with color

color='#EE3224',

# with label the first value in first_name

label=df3['Region'][0])

# Create a bar with mid_score data,

# in position pos + some width buffer,

plt.bar([p + width for p in pos],

#using df['mid_score'] data,

df3['Land'],

# of width

width,

# with alpha 0.5

alpha=0.5,

# with color

color='#F78F1E',

# with label the second value in first_name

label=df3['Region'][1])

# Create a bar with post_score data,

# in position pos + some width buffer,

plt.bar([p + width*2 for p in pos],

#using df['post_score'] data,

df3['Sea'],

# of width

width,

# with alpha 0.5

alpha=0.5,

# with color

color='#FFC222',

# with label the third value in first_name

label=df3['Region'][2])

# Set the y axis label

ax.set_ylabel('Arrival count')

# Set the chart's title

ax.set_title('Total arrival count by mode of transport by region in 2014')

# Set the position of the x ticks

ax.set_xticks([p + 1.5 * width for p in pos])

# Set the labels for the x ticks

ax.set_xticklabels(df3['Region'])

# Setting the x-axis and y-axis limits

plt.xlim(min(pos)-width, max(pos)+width*4)

plt.ylim([0, max(df3['Air'] + df3['Land'] + df3['Sea'])] )

# Adding the legend and showing the plot

plt.legend(['Air', 'Land', 'Sea'], loc='upper left')

plt.grid()

plt.show()

这是我的图表。正如您所观察到的,大多数图形是看不见的。在

UsQQj.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值