小编Ash*_*ams的帖子

如何在水平条形图 matplotlib 的条形内部写入文本?

到目前为止,我的代码给了我一些看起来像这样的东西: 在此输入图像描述

如果可能的话,我想在酒吧里写下这样的内容: 在此输入图像描述

到目前为止,这是我的基本代码:

我想放进Disease酒吧

import matplotlib
from matplotlib import pyplot as plt
import pandas as pd 
import numpy as np

x = [u'Rimegepant',u'Rimegepant',u'Zavegepant',u'Zavegepant',u'Troriluzole',u'Troriluzole',u'Troriluzole',u'Verdiperstat',u'Verdiperstat']

y = [4,3,3,3,2,3,3,3,3]

Disease = ['Acute Treatment of Migraine','Preventive Treatment of Migraine','Acute and Preventive Migraine','Lung Inflammation COVID-19',"Alzheimer's Disease", "OCD", "Spinocerebellar Ataxia", "Multiple System Atrophy", "Amyotrophic Lateral Sclerosis"]

fig, ax = plt.subplots()    
width = 0.75 # the width of the bars 
ind = np.arange(len(y))  # the x locations for the groups
ax.barh(ind, y, width, color="green", align='edge') …
Run Code Online (Sandbox Code Playgroud)

python label matplotlib bar-chart

4
推荐指数
1
解决办法
6102
查看次数

标签 统计

bar-chart ×1

label ×1

matplotlib ×1

python ×1