猫史档案馆


wowhhh

wowhhh

Lv.1

i人

获赞:26收藏:2浏览:61作品收藏:0
回复帖子评论
上一页1 页 / 共 1下一页

如何制作出精美的残影效果(含2种-适合萌新,大佬勿喷) 中回复

emotion_编程猫_搓头

2022-11-26T19:34:13 点赞:0

为什么我做的聊天室发送一次出现两条信息? 中回复

emotion_喵

n = 12
X = np.arange(n)

Y1 = (1-X/n)*np.random.uniform(0.5,1.0,n)

Y1 = (1-X/n)*np.random.uniform(0.5,1.0,n)



# 由于返回值,进过提取是str,操作小数位数不方便,外面提前处理好

p1 = plt.bar(X,np.round(Y1,2),width=0.8,facecolor='deeppink',label='uniform')



def autolabel(rects):

    """Attach a text label above each bar in *rects*, displaying its height."""

    for rect in rects:

        height = rect.get_height()

        plt.annotate('{}'.format(height),

                    xy=(rect.get_x() + rect.get_width() / 2, height),

                    xytext=(0, 3),  # 3 points vertical offset

                    textcoords="offset points",

                    ha='center', va='bottom')



# 为什么有两个hight

def add_labels(rects):

    for rect in rects:

        height = rect.get_height()

        plt.text(rect.get_x() + rect.get_width()/2,height,height, ha='center', va='bottom')

        rect.set_edgecolor('white')



# add_labels(p1)



autolabel(p1)



plt.legend(loc='best')

plt.show()   

2022-12-25T18:17:09 点赞:0

通知大家一件事 中回复

总之,只要能不开协作就不开

2023-01-13T21:50:31 点赞:0