如何反转 PyQtGraph 中 ScatterPlotItem 的 Y 轴

发布于 2025-01-17 19:06:13 字数 544 浏览 3 评论 0原文

我想用索引显示散点图中的点,就像它是一个矩阵一样,原点左上角反转 Y 轴:

0,0 1,0
0,1 1,1 

而不是默认原点位于左下角。

0,1 1,1
0,0 1,0

输入图片此处描述

我尝试过:

plot = pg.ScatterPlotItem(...)
plot.getViewBox().invertY(True) #  view box is NoneType

按照此处的建议反转PyQtGraph 中的 Y 轴 没有运气。

I want to display points in a scatter plot with indices as if it were a matrix, origin top left inverting the Y axis:

0,0 1,0
0,1 1,1 

instead of default where the origin is the lower left.

0,1 1,1
0,0 1,0

enter image description here

I tried:

plot = pg.ScatterPlotItem(...)
plot.getViewBox().invertY(True) #  view box is NoneType

as suggested here Inverting the Y axis in PyQtGraph with no luck.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放肆 2025-01-24 19:06:13

参考官方 doc ,当您在轴内显示数据时,您会结束数据如图所示,使用plotItem对象为A 容器向上(直接或间接)。

假设您绘制了以下内容:

plot_widget = PlotWidget()
plot_item = plot_widget.plotItem
plot = pg.ScatterPlotItem(x=[0, 0, 1, 1], y=[0, 1, 0, 1], size=20.0)
plot_widget.addItem(plot) # Or equivalently, plot_item.addItem(plot)

您可以简单地做:

plot_item.invertY(True)

<

a href =“ https://i.sstatic.net/pttj8.png” rel =” nofollow noreferrer“> ”在此处inter

Referring to the official doc, when you have data displayed within axes, you end up (directly or indirectly) using a PlotItem object as a container, as shown in the figure.

enter image description here

Assuming you are plotting something like the following:

plot_widget = PlotWidget()
plot_item = plot_widget.plotItem
plot = pg.ScatterPlotItem(x=[0, 0, 1, 1], y=[0, 1, 0, 1], size=20.0)
plot_widget.addItem(plot) # Or equivalently, plot_item.addItem(plot)

You can simply do:

plot_item.invertY(True)

And here is the result:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文