Mpld3: blurry image - matplotlib

I created a matplotlib figure (matplotlib on server) and displaying it with mpld3.draw_figure (nodejs on client) only gives blurry images, similar to the ones here:
How to 'turn off' blurry effect of imshow() in matplotlib?
mpld3.draw_figure(`chartBox-${round}`,chart,false,true)
Interpolation setting 'nearest', 'none', did not change anything:
plt.imshow(G,interpolation='nearest')
I assume its some interpolation problem... maybe also there is a 0.5 shift, so that gridpoints 1 -> 1.5 and are then interpolated.

First switching back to matplotlib 1.5.1 and then
mpl.use('Agg')
solved it
see here:
Generating a PNG with matplotlib when DISPLAY is undefined

Related

OpenCV is not graying an image with cv2.cvtColor when displayed with matplotlib

I tried to gray an image but it does not work properly like it should. It just applied a kind of filter as you can see by using cv2.COLOR_BGR2GRAY function. Kindly someone help me to get over with this issue.
Your issue is that you're using matplotlib to show your grayscale image. Matplotlib applies a colormap. By default that's a colorful one.
Add cmap="gray" in your imshow call: plt.imshow(img_gray, cmap="gray")

Fix for pyqtgraph bug when ignoring dpi display setting and using 96 dpi

I have the same issue as described in link below, where the axes of my plot aren't rendered correctly if I set the Qt.AA_Use96Dpi attribute of my QApplication to make my application invariant across different display settings.
How to stop display resolution from affecting axes in pyqtgraph plots
The solutions proposed solve the issue of broken axes if Qt.AA_Use96Dpi is not used, but wondering if there is fix that works with it enabled.

matplotib: two overlaid transparent images look different when saved as svg or png

I'm trying to overlay two transparent images with matplotlib and save the result, but the result looks different depending on the file type. Specifically it's much more washed-out when saving to svg.
Here's an example. In this case, I could just add the two images before displaying them, but this is just a simple example. In reality what I'm trying to do is more complicated (images of different sizes with different colormaps), so they have to be plotted separately.
Example code:
f, ax = plt.subplots(figsize=(2,2))
ax.imshow(np.eye(3), alpha=.5)
ax.imshow(np.eye(3)[::-1], alpha=.5)
f.savefig('example.png')
f.savefig('example.svg')
The png file looks just like it does on the screen, but the svg file looks washed out. I would like to know how to save as svg, without the washed-out effect (i.e. it should look like it does on the screen).
As a bonus question, why does the png plot appear different depending on the order in which I plot the transparent images? The second image always looks stronger. Interestingly, in the svg, both are equally washed out.
Example saved as png:
Example saved as svg:
matplotlib version: 3.1.3
python version: 3.7.7
Thanks for any tips!
I'll post what I think is going on, but if someone can answer with more legit information I'll accept it.
I think that every time you call imshow with an alpha value, it blends the current image in the axis with the new image, using (new * alpha + current * (1-alpha)). The problem with this is that if you display 10 images each with alpha 0.5, then the first image is attenuated to nothing by the iterative blending, whereas the last image gets to be 50% of the final result. Nonetheless this is apparently the method used for rendering to the screen and saving to png.
In contrast, when saving to svg, it saves each image as a separate overlay with its own alpha. The svg container or renderer then uses some more intelligent method that considers all overlaid images at once. However, in my particular case, this leads to a more washed-out look because all the images are partially transparent.

Removing background on a 3d plot Julia

I am having some real trouble trying to plot nice things with Julia.
I first used PyPlot which I was happy with but I had to be able to change the angle on a 3D plots (in that case using surface) so I now use Plots directly with the camera speficication. I would like to remove the background on a 3D plot.
using PyPlot, the following command :
ax=gca(); ax:set_axis_off
works fine.
When using Plots, I tried the following :
using Plots; pyplot(grid=false)
and then my code for the surface, and it does not change the output.
I also tried the first example on this page :https://github.com/JuliaPlots/Plots.jl/pull/695 and grid specification does not work (grids are the same on every area of the layout).
I tried after updating every package and it still does not work.
Does anyone have an idea about what would the problem be please?
Thank you in advance !

Gnuplot - pdf filesize increases when removing tilt

When I plot a densityplot using something like
plot 'xyz.dat' w image u 1:2:3
the filesize is nice and small how it should be.
However if I remove an experimental tilt with
plot 'xyz.dat' w image u 1:($2+tilt*$1):3
the figure is not rendered anymore and plot as a vectorial graphics, resulting in a filesize of some Megabyte. This happens with pdf and pdfcairo terminal (eps is even larger).
Anyway to force gnuplot into rasterizing only the plot and not the axes etc?
And is this a bug since I didn't change any other options (btw: still v4.6)?
Thanks alot!