在 Python 中向 PyQT 图表添加单独的轴标签?
我正处于项目的最后部分,我们只需要制作一个图表,显示节目和电影的数量及其收视趋势。我有 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)
I'm in the final portion of my project and we just need to make a graph showing the number of shows and movies with their rating trend. I have 4 different bar graph items and I was wondering if there's a way to add labels to each individual bar? For example here's one of the bars
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用一组 TextItem 并将栏设置为其父级:
请注意,您不需要创建单独的条形,只要它们属于同一组并共享相同的颜色即可:只需添加
x
和height
作为列表他们的立场和价值观。You could use a group of TextItem and set the bar as their parent:
Note that you don't need to create individual bars as long as they are part of the same group and share the same colors: just add the
x
andheight
as lists of their positions and values.