Bokeh shows plot blurred on windows - python

I am using bokeh for plotting. With my current settings, bokeh shows some text and lines kind of blurred (anti-aliased?). This is not really noticeable on my monitor, but on some projectors, especially when doing screenshots and inserting them into presentations, it looks weird.
As requested, a minimum working example:
from bokeh.plotting import figure, show
p = figure(plot_width=1000, plot_height=600,
title="TestTitle", x_axis_label = "Length [cm]", y_axis_label="Height [m]")
p.xaxis.axis_label_text_font_style = "normal"
p.xaxis.axis_label_text_font_size = "12pt"
show(p)
I am using Windows 7 and tried this in the current versions of Chrome and IE. Python 3.6, bokeh version 0.13.0. The first image is taken from the example, the second is taken from my real code:
I tried different figure sizes, but the problem persists - maybe I am trying the wrong ones? Anything I can do about this, except simply trying different sizes until something "works"? Setting px instead of pts seems to make it worse...

Regarding the text, it is rendered on to a raster HTML canvas, and the details of how this is done are entirely dependent on the browser canvas implementation. (FWIW things look better on any browser on OSX than the above image.) There's not anything we can to change how a specific browser renders text, and not much I can suggest except to make much bigger canvas sizes if you need to show something extremely magnified.
Regarding the aliasing of the axes and tick marks, I can't reproduce anything like that on any OSX browser (Safari, FF, or Chrome). It definitely appears to be a Windows-specific issue. It's possible there are issues that could be addressed, e.g a different HiDPI setting, or half-pixel offsets, but it would take investigation to try and determine what can be done. A Github issue with details would be appropriate, but I can't speculate when it might be addressed (we are under-resourced and no core contributors are regular windows users).

Related

DashPlotly : Coarse display of figures on small screen

I am currently working on a data visualization web application with DashPlotly. My goal is to create "stylized" dashboards with DBC. I have a problem with the size of the plotly figures, they are "too zoomed". Indeed, the ideal rendering for me would be the rendering provided with the browser zoomed out to 67%. I attach a GIF to illustrate my point.
I wonder then if it is possible to have a less coarse rendering of plotly figures when the browser is zoomed to 100% ?
I specify that I work on a small screen (laptop 15") and I would like the rendering of the figures to be the same for all types of screens.
For this example I applied a css zoom directly on the DBC card but this is not a viable solution in the long run.
If someone has already encountered a similar problem, I'm interested ;)
Have a good day
I finally found a solution to my problem. What happens when you zoom out with the browser is that the font size of the elements in the figure decreases. So I simply reduced the font size of my plotly figures...
fig.update_layout(
font=dict(
size=12
)
)

Absolute positions in mpld3 graphs

I'm trying to define a custom plugin for mpld3, and I'm struggling with positions. More particularly, by default, SVG generated by mpld3 come with Move and Zoom buttons, which change the view of the graph. When I was trying to display things (like text), I stumbled upon a strange behavior where positions are set relatively to the current view. It means that if I display a text next to a point A(10,10) and then move the view, the point will still be at (10,10) but the text will move because its position is relative to the current view.
So I wanted to think again and start with a minimal example which should work : this example from the mpld3 documentation. In the demo, you can see the behavior I want : positions are absolute (when you move the view, cursor position is set according to the grid)..
But if I copy-paste the exact same code in Pycharm and execute it, positions are relative to the view which is even more strange :
My guess is it's a version problem. I don't know which versions are used in the hosted demo example. I use mpld3==0.5.1, matplotlib==3.2.1 and numpy==1.19.2.
Do you have an idea so I can manage to deal with absolute positions like in the example ?
I've managed to make it work. It turns out that downgrading mpld3 to version 0.3 does what I want. I'm sure there is a better solution (because I can't take advantage of the latest version) but it gets the job done.

How to make jupyter pythreejs plots larger?

I've been playing around with pythreejs, and, while it seems to be a good solution to the problem of visualizing 3D graphics in a jupyter notebook, I haven't been able to find any documentation about what jupyter is actually doing under the hood or what API exists for managing the widget. Currently, when I make a pythreejs plot (e.g., by calling display() on a pythreejs.Renderer object), I get a tiny little output window. How can I edit the size (and other properties) of this window? How can I see what the properties are?
Thanks!
I discovered by experimentation that this can be controlled by passing the width and height parameters to the pythreejs.Renderer constructor. I would, however, appreciate any answer that points me toward better documentation for pythreejs or some philosophy regarding why/how certain aspects of the three.js API were modified for Python's API.

How to save matplotlib figure in max windows form instead of default size?

Anyone know how should i work around with that?
I know there is save button which I could do it manually but I am plotting 100+ graph so I hope there will be a way to doing it automatically?
I was using 'TkAgg' backend and I look up for any possible solution around. By using the following at the end of my plot function.
manager = plt.get_current_fig_manager()
manager.resize(*manager.window.maxsize())
plt.savefig(r'C:\Users\310293649\Desktop\PlotFigure\TESTING.png')
plt.show()
EDIT: Tried with this as well but still I was able to plt.show() the figure in the desired way I prefer which is full windows size. But it still automatically save all of my figure in minimize default form.
wm = plt.get_current_fig_manager()
wm.window.state('zoomed')
plt.savefig(r'C:\Users\310293649\Desktop\PlotFigure\TESTING.png')
plt.show()
Below is what I got after plt.show() from above command,
plt.savefig result that I got:
As you can see The code managed to show the plot in max windows size but it still automatically saved the plot with default size So I was wondering if it is possible or is there any solution to save the matplotlib figure in max windows size automatically? OR there is no way I can do that?
Below images is the figure when I done it manually with the save figure button in matplotlib:
EDIT: How to make pylab.savefig() save image for 'maximized' window instead of default size - Most of the answer here refer to showing the figure in full windows form but when it come to saving the max windows automatically(it still save it in the normal size)...you can see the author of the ques have raised up the issue in the comment section of all of the answer but was not answered.
Apparently, this is a bug introduced in Matplotlib 2.0 (January '17).
See here and here.
There seems to be a fairly simple code change to fix this here, but you'll have to apply it yourself since it's not included in any released version yet (it's planned for 2.1.1 2.2).

Making 3D anaglyphs with Mayavi?

It's all in the title: I would like to make red-cyan anaglyphs (you know, these pictures you use coloured glasses to see in 3D) of simple shapes (like points3d plots) with Mayavi. Is there such a feature? Otherwise, would you have any advice for implementing it?
EDIT : Okay, that was simple: just hit '3' in the interactive window and this sets the stereoscopic mode on. However I'd be interested in ways to configure this option, which does not seem to be documented.
Yes the interactive renderer is very poorly documented. A lot of mayavi is very badly documented, but at the least the code is often well written to figure stuff out.
Programatically you can adjust it by editing scene.render_window.stereo_render.
The source code of tvtk InteractiveRenderStyle has the following comment, also:
Some systems support crystal Eyes LCD stereo glasses; you have to invoke
set_stereo_type_to_crystal_eyes() on the rendering window.
For more configuration, you'd probably have to read the tvtk source.

Categories

Resources