Open RoyiAvital opened 1 year ago
Does the equivalent plot work in Python?
AFAIR Bokeh.jl doesn't properly support units yet - I've never taken the time to understand how they work in bokeh.
@cjdoris , All I'm after is being able to set the number of pixels to be drawn.
In MATLAB I can do it as axes(hF, 'Units', 'px', 'Position', [x, y, width, height]);
.
I want to display images in Bokeh.jl
and I need them to be 1:1
.
Namely each pixel of the image to be exactly a single pixel on the screen.
I thought dh_units
are the way to do so.
I gave it a try using Python:
import numpy as np
from bokeh.plotting import figure, show
x = np.linspace(0, 10, 300)
y = np.linspace(0, 10, 300)
xx, yy = np.meshgrid(x, y)
d = np.sin(xx) * np.cos(yy)
p = figure(width=600, height=600, x_range = (0, 300), y_range = (0, 300))
p.image(image=[d], x=0, y=0, dw=300, dh=300, dw_units = 'screen', dh_units = 'screen', palette="Sunset11", level="image")
p.grid.grid_line_width = 0.5
show(p)
It indeed gives a 1:1 look.
There is a different issue there, something I don't understand about the axis.
The image itself is perfectly aligned and its actual size on screen is 300x300
.
So units indeed work on Python.
Look at the following code:
This works and open a window with the noise rendered.
Now I want the image size to match the number of pixels in the data. So I need to set the units to
screen
:Yet this time the browser window opens but nothing is displayed.
On Windows 10 with Julia
1.9.1
on a clean environment.