我正處于專案的最后一部分,我們只需要制作一個圖表,顯示節目和電影的數量及其評分趨勢。我有 4 個不同的條形圖專案,我想知道是否有辦法為每個單獨的條形添加標簽?例如這里的酒吧之一
y4 = [fourth]
x4 = [4.33]
bg4 = pg.BarGraphItem(x=x4, height=y4, width=0.2, brush='red', setLabel="Shows Down")
bg4.setX(0)
bg4.setY(0)

uj5u.com熱心網友回復:
您可以使用一組TextItem并將欄設定為它們的父項:
text = pg.TextItem('Some bar', angle=90, color='#ffff00')
# reparent the item and make it a child of the bar
text.setParentItem(bg4)
# set the position to the x of the bar
text.setX(x4[0])
# use the x as left of the text and the y as vertical middle (referenced
# to the text orientation)
text.setAnchor(QPointF(0, .5))
請注意,您不需要創建單獨的條,只要它們屬于同一組并共享相同的顏色:只需添加x和height作為它們的位置和值的串列。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/439431.html
