lets-plot icon indicating copy to clipboard operation
lets-plot copied to clipboard

Can't load image in PyCharm's Jupyter notebook

Open egonchen98 opened this issue 2 years ago • 8 comments

The image often don't show up properly when using jupyter notebook in Pycharm. However, everything goes well in VS code jupyter notebook.

egonchen98 avatar Jun 25 '23 05:06 egonchen98

By "image" do you mean geom_imshow() or not a specific "geom" but any lets-plot figure?

Do you pass any values to LetsPlot.setup_html() call in the head of the notebook?

alshan avatar Jun 26 '23 15:06 alshan

I am using ggplot() + geom_xxx() function to draw images in the Jupyter notebook.

When I set LetsPlot.setup_html(offline=True), both PyCharm and VS code works fine for me, but the image is coarse.

When I set LetsPlot.setup_html(offline=False), only Jupyter notebook in VS code works fine and the notebook in PyCharm can't load the image at all.

Thank you!

egonchen98 avatar Jun 27 '23 08:06 egonchen98

My guess is that PyCharm blocks the notebook' access to the internet. Please make sure you have "Trusted" checkbox selected in the notebook' toolbar: image

And you can call setup_html() with no parameters: LetsPlot.setup_html(). As long as you are on-line that is.

alshan avatar Jun 27 '23 19:06 alshan

Thank you alshan. After selecting the "Trusted" checkbox, PyCharm does load the output image. However, the image is of poor quality and not clear enough, which just looks like that let-plot still works in an offline mode.

Is it a problem of computer memory? Can I do something to improve the quality of the output image?

Thank you.

image

egonchen98 avatar Jun 28 '23 07:06 egonchen98

Could you try to export to SVG : ggsave(p, "a.svg") and then open this svg file in PyCharm or in a browser?

alshan avatar Jun 28 '23 17:06 alshan

Could you try to export to SVG : ggsave(p, "a.svg") and then open this svg file in PyCharm or in a browser?

After saving the plot to a svg file and opening it, the image quality is as good as I want. I seems that it is a problem of PyCharm. Can I do something else to view high quality image in PyCharm directly?

Thank you.

egonchen98 avatar Jun 30 '23 05:06 egonchen98

Can't say what else we can do. On my macbook retina display plots look perfect in PyCharm. If you have 4K monitor than there might exist some settings allowing to improve the picture quality at the expense of performance perhaps. I recommend to contact PyCharm support.

alshan avatar Jun 30 '23 16:06 alshan

Thank you! I will contact PyCharm support.

egonchen98 avatar Jul 01 '23 00:07 egonchen98