python barplot宽度_在matplotlib barplot中,如何确保以相等的宽度呈现非常小的条形图?...

我正在matplotlib中创建一个条形图,其中有很多非常窄的条形图。下面是一些示例代码:import matplotlib.pyplot as plt

import numpy as np

x = np.arange(100)

y = np.random.poisson(1, size=100)

fig, ax = plt.subplots(figsize=(8, 1))

ax.bar(x, y, width=1, facecolor='red', edgecolor='white', linewidth=1)

ax.grid(color='white', linewidth=1, linestyle='-')

# some plot aesthetics

for spine in ['right', 'top', 'left']:

ax.spines[spine].set_visible(False)

ax.xaxis.set_ticks_position('bottom')

ax.yaxis.set_ticks_position('none')

ax.yaxis.set_major_locator(plt.MultipleLocator(1))

ax.yaxis.set_major_formatter(plt.NullFormatter())

jVZnl.png

请注意,由于像素分辨率有限,条形图在渲染宽度上有明显变化。在

在matplotlib中创建此绘图的最佳方法是什么,同时确保渲染结果具有等宽的条形图?在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值