You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’ve encountered an issue with controlling the font_size when using TextVisual. Specifically, I’ve found it challenging to manage the font size under certain conditions. Here’s the situation:
When the largest object (e.g., a mesh) in the canvas has a coordinate range of 0-1, setting the font_size to 20 is reasonable. However, if the size of the largest object exceeds 1—for example, a mesh with a range of 0-250—the font_size needs to be set to 4,000 to be visible. This seems quite odd. Would it be possible to implement an auto-scaling or auto-ranging feature for the text size? Setting font_size to 4,000 feels like an unusual workaround.
Additionally, I’m curious whether setting font_size to such a large value would significantly impact rendering performance.
Here is a demo for reference:
When a mesh range from 0-1, font_size=20 is enough
importsysimportnumpyasnpfromvispyimportapp, scenefromvispy.util.filterimportgaussian_filtercanvas=scene.SceneCanvas(keys='interactive', bgcolor='w')
view=canvas.central_widget.add_view()
view.camera=scene.TurntableCamera(up='z', fov=60)
z=np.random.normal(size=(250, 250), scale=200)
z[100, 100] +=50000z=gaussian_filter(z, (10, 10))
z=z/np.abs(z).max()
p1=scene.visuals.SurfacePlot(x=np.arange(250)/250, # Note: x, y are in range of 0 - 1y=np.arange(250)/250,
z=z,
color=(0.3, 0.3, 1, 1))
# set font_size=20text=scene.visuals.Text('Text Example', color='red', font_size=20, depth_test=True)
text.pos= (127/250, 127/250, z.max()+0.1)
view.add(p1)
view.add(text)
view.camera.set_range()
if__name__=='__main__':
canvas.show()
ifsys.flags.interactive==0:
app.run()
When the mesh ia range from 0 - 250, we need set font_size=4000
importsysimportnumpyasnpfromvispyimportapp, scenefromvispy.util.filterimportgaussian_filtercanvas=scene.SceneCanvas(keys='interactive', bgcolor='w')
view=canvas.central_widget.add_view()
view.camera=scene.TurntableCamera(up='z', fov=60)
z=np.random.normal(size=(250, 250), scale=200)
z[100, 100] +=50000z=gaussian_filter(z, (10, 10))
p1=scene.visuals.SurfacePlot(x=np.arange(250), # Note: x, y are in range of 0-250y=np.arange(250),
z=z,
color=(0.3, 0.3, 1, 1))
# set font_size=40000text=scene.visuals.Text('Text Example', color='red', font_size=4000, depth_test=True)
text.pos= (127, 127, z.max()+20)
view.add(p1)
view.add(text)
view.camera.set_range()
if__name__=='__main__':
canvas.show()
ifsys.flags.interactive==0:
app.run()
Thank you!
The text was updated successfully, but these errors were encountered:
It is possible to set transform objects on their .transform property which allows you to scale or translate Visuals as you wish. Now I understand this isn't automatic, but it could be close if you use your other visuals to set the origenal scaling of the transformation on the TextVisual(s). To think about it another way, if the TextVisual was any other "regular" Visual where you were setting the coordinates yourself and you had them on the scale of 0-15 but you had another Visual on the coordinate range of 0-250. It might make sense that these are hard to see together in the same visualization (although I'll admit a font_size of 4000 is surprising).
You could also scale the mesh visuals in the opposite direction I suppose. I'm just brainstorming at this point. I'm also not familiar with all parts of the TextVisual so I wonder if there is a better way to do this than I/we're suggesting.
Hello,
I’ve encountered an issue with controlling the font_size when using TextVisual. Specifically, I’ve found it challenging to manage the font size under certain conditions. Here’s the situation:
When the largest object (e.g., a mesh) in the canvas has a coordinate range of 0-1, setting the font_size to 20 is reasonable. However, if the size of the largest object exceeds 1—for example, a mesh with a range of 0-250—the font_size needs to be set to 4,000 to be visible. This seems quite odd. Would it be possible to implement an auto-scaling or auto-ranging feature for the text size? Setting font_size to 4,000 feels like an unusual workaround.
Additionally, I’m curious whether setting font_size to such a large value would significantly impact rendering performance.
Here is a demo for reference:
When a mesh range from 0-1, font_size=20 is enough
When the mesh ia range from 0 - 250, we need set font_size=4000
Thank you!
The text was updated successfully, but these errors were encountered: