Open ghoulapool opened 5 months ago
For good news, I was able to reproduce the issue which boiled down to a formatting quirk of the pyqtgraph library.
If you add an additional dimension to the ndarray, the plot works as expected:
Part of this is detailed in the docstring for render_data
in the abstract BasePlot2DPane
class, but the documentation leaves much to be desired here.
Still, the solution is not intuitive. I figured with the data being in the (N,2) shape, this would work as it should, but that's clearly not the case.
Looking into this a little further to see if this can be made more intuitive.
Found the issue:
See line 265. We have assumed the user will specify a callback which returns multiple curves worth of data. In this case, the return shape was (N,2) which represents only one curve. As such, each point was plot as a unique element. I should have noticed that sooner from the different point colors in the original post.
Need to look into switching over to this interface in PyQtGraph:
For now, I'm updating the documentation for the render method on BasePlot2DPane
.
Posting this here as a reference:
For those who haven't seen the None
syntax in the ndarray indexing before, it was a little odd to me as well the first time I saw it. Basically, it just means "insert a new dimension of size 1 here".
The result is the original ndarray with shape (N,2) is returned with shape (1,N,2) as a result of the None inside the index statement.
In other words, this is equivalent to
tuple destructuring
modes_by_result.reshape(1, *modes_by_result.shape)
and
tuple concatenation
modes_by_result.reshape( (1,) + modes_by_result.shape )
Here's an image:
Here's the code that created it - shouldn't the x axis range from the smallest to largest value?
. . .