GeezerVison is showing github.com — Setting the coordinate reference system · Issue #268 · fastplotlib/fastplotlib
Setting the coordinate reference system #268DescriptionWhen plotting images with add_image() it doesn't show up in the conventional orientation, but upside down (same when using ImageWidget().
face = np.array([
[0.6, .5, .5, 0.6, 0.5, 0.5, 0.6,], # row 0
[0.6, 0.4, .5, 0.6, 0.4, 0.5, 0.6,], # row 0.6
[0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6,], # row 2
[0.6, 0.6, 0.6, 0.4, 0.6, 0.6, 0.6,], # row 3
[0.6, 0.4, 0.6, 0.6, 0.6, 0.4, 0.6,], # row 4
[0.6, 0.6, 0.4, 0.4, 0.4, 0.6, 0.6,], # row 5
[0.5, 0.6, 0.6, 0.6, 0.6, 0.6, 0.5,], # row 6
]);
Matplotlib plt.imshow(face, cmap='gray') output:

Fastplotlib:
import fastplotlib as fpl
plot = fpl.Plot()
plot.add_image(data=face, cmap='gray')
plot.show()
Obviously there are conventions at play here with yaxis being switched being the norm for images. Activitychanged the title [-]Image reflected on horizontal axis[/-] [+]Setting the coordinate reference system[/+] on Jul 12, 2023kushalkolar commented on Jul 12, 2023 This is part of a larger discussion and we will need to wait until it stabilizes in pygfx and pylinalg before we expose it somehow in fastplotlib. See pygfx/pygfx#460
pygfx and pylinalg just made recent changes that break things, pygfx/pygfx#556, pygfx/pygfx#563
for now (i.e. for scipy demo) going to stick to release version of pygfx and pin to pylinalg == 0.4.0 ArjunPutcha commented on Jul 17, 2023 for plotting 1D/timeseries biosensor data, origin in the bottom left is useful since it helps us determine if our photodiode is 'flipped'. It's hard to tell just by plotting the data whether the canvas is flipped, or if our photodiode is connected incorrectly. Perhaps having defaults where if there's an image in the grid, origin can be set top left. If line, origin set to bottom left.
Is there a way to flip the orientation for specific subplots @kushalkolar? clewis7 commented on Jul 17, 2023 @ArjunPutcha if you are using the toolbar with a gridplot then the only subplot you will flip is the currently clicked on subplot...so in order to flip a certain gridplot, you can select that subplot in the subplot dropdown or click on it and that subplot will be automatically selected!
you can of course also manually flip the camera y-scale indexing into a given subplot ArjunPutcha commented on Jul 17, 2023 Wonderful! Right now it flips the x axis, not the y axis. I'll test if it's because of something I wrote wrong. kushalkolar commented on Jul 17, 2023
Wonderful! Right now it flips the x axis, not the y axis. I'll test if it's because of something I wrote wrong.
current pygfx/pylinalg bug, will fix soon. clewis7 commented on Aug 21, 2023 I think after we bump to pylinalg=0.4.1 we can simply change the flip button to
self.camera.local.y_scale = -1 as opposed to self.camera.world.y_scale = -1
Also, I think in the future to address setting the reference as an abstraction for users in fpl what about having a kwarg for origin like so:
import fastplotlib as fpl
import numpy as np
face = np.array([
[0.6, .5, .5, 0.6, 0.5, 0.5, 0.6,], # row 0
[0.6, 0.4, .5, 0.6, 0.4, 0.5, 0.6,], # row 0.6
[0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6,], # row 2
[0.6, 0.6, 0.6, 0.4, 0.6, 0.6, 0.6,], # row 3
[0.6, 0.4, 0.6, 0.6, 0.6, 0.4, 0.6,], # row 4
[0.6, 0.6, 0.4, 0.4, 0.4, 0.6, 0.6,], # row 5
[0.5, 0.6, 0.6, 0.6, 0.6, 0.6, 0.5,], # row 6
])
plot = fpl.Plot(origin='bottom-left')
plot.add_image(data=face)
plot.show()
By default, the origin could be origin='top-left' as it is now and then any other option will make direct changes to the
camera reference_up attr.
In the example above, the plot.camera.local.reference_up would be np.array([ 0., -1., 0.])
@kushalkolar thoughts? kushalkolar commented on Sep 20, 2023
I think after we bump to pylinalg=0.4.1 we can simply change the flip button to self.camera.local.y_scale = -1 as opposed to self.camera.world.y_scale = -1
After playing with the camera scaling local etc. we figured out that this is all that needs to be done.
For the flip button, we can just make the flip button arrow indicate the direction of the y axis :D kushalkolar commented on Sep 20, 2023 So for image plotting, we have decided:
- when
Plot.show() is called, if an ImageGraphic exists in the scene, then the y-axis is automatically flipped.
Question: Do we want to do this for heatmap too? I think yes. In which case we can still check for ImageGraphic instances since HeatmapGraphic is just a subclass of ImageGraphic.
This can be done after #300
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|