Plots.jl: how to savefig the plot that VSCode displays

When I plot a figure (with Plots/GR) in VSCode, I get this:

Now if I try to save it with savefig, I get:

The saved figure does not correspond to the one VSCode displays. I tried saving the figure in different formats (pdf, svg, png), but the results always differ from the VSCode-shown figure.

What is the output that VSCode displays? Can I save figures with that output format? (I know I can save them from the VSCode panel, but I want to script that)

1 Like

An update:

Within VSCode, I can save the figure as svg. In the VSCode viewer, the image is nice (even if I open the saved svg):

But if I open it with other viewers, it is not as pretty:

So the issue is a visualization one, it seems that VSCode somehow smoothes the color scale and the picture looks nicer there than in Inkscape or other image viewers.

1 Like

Have you also tried opening the SVG file in a web browser?

1 Like

Perhaps you could post the file somewhere…

Worth remembering that there are subtle differences in the way SVG is interpreted by different software. See SVG 1.1 Full Static Support for a glimpse into the madness :grinning_face:

1 Like

Indeed, in the browser it displays like in VSCode.

It is a visualization issue, then. It’s a pity, as the work of tuning the figure in VSCode can be wasted (or, which is what I do now, end up print-screening the figure at the end…).

There is a workaround provided in SO that you may be able to implement in Julia to edit the SVG file so that the display in Inkscape looks similar to VSCode.

Well, that’s nice, but it won´t solve the issue of being able to save the plots with the same appearance that they have when displayed in VSCode. If SVGs have these displaying issues, it would be nice to have a way to save the plots in PNG or TIF formats with the same appearance they have in the VSCode pane. That might be an UI feature, though (although not being able to script such figure generation is an inconvenience).