Flip images when ranges are reversed
See original GitHub issueHello,
I’m new to Bokeh, and it might be that I’m using the library wrong, but in most of the image libraries the [0,0] pixel refers to the top left pixel of the image, while in Bokeh (I have not been able to change it) the [0,0] coordinate refers to the bottom left pixel of the image. This simple script to load and plot an image:
import bokeh.plotting as plt
from skimage.io import imread
lenna = imread('/tmp/lenna.png', flatten=True)
p = plt.figure(x_range=[0,10], y_range=[0,10])
p.image(image=[lenna], x=0, y=0, dw=10, dh=10, palette='Greys9')
plt.show(p)
Results with the image plotted upside down, as seen in the attached images (image is also converted to grayscale but this is not relevant):
I’ve tried reversing the range to [10, 0]
but this results in displacing the image, not fliping the y axis. The only way I’ve found to plotting it right is by flipping the numpy array lenna[::-1]
before sending it to plot (but I guess it should be a better way).
Is there a way of doing it? Is it a bug? Or am I using the library wrong?
Thank you
Issue Analytics
- State:
- Created 9 years ago
- Comments:17 (7 by maintainers)
I’m going to +1 this because it’s still an issue in 12.10.
I would propose adding an option
invert_y
with a default offalse
, which would ensure backwards compatibility.origin
implies translation, not inversion of any axes.Flip the image first using
lenna = np.flipud(lenna)