1

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.

Lora
  • 65
  • 1
  • 5

1 Answers1

0

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

Buzz
  • 1,102
  • 1
  • 9
  • 24