-1

I find several links(e.g. this one) about the size or resolution of figures plot by matplotlib.

Like enter image description here, we can use pl.show(), and zoom in or zoom out before we save the figure. We can see as many details as possible in this way.

However, after we specify a dpi value in pl.savefig and save the whole figure*(png format), the details like above are lost. enter image description here

Even we use a svg format, the improvement is limited like svg

What is the best way then? After we save the figure, can we display it and adjust it like pl.show()?

Community
  • 1
  • 1
questionhang
  • 735
  • 2
  • 12
  • 31
  • "the details are lost" -> which details? I don't think that anyone can help you unless you provide an example (code, resulting figures, ..) – Bart Apr 02 '16 at 16:16
  • @Bart resolution, pl.show() has a much better resolution. – questionhang Apr 03 '16 at 01:35
  • Again, show us an example, or preferably create a minimal working example which reproduces the problem. I've worked with matplotlib for years, and can't remember ever having seen the problem that you are describing, so it's nearly impossible to think of a reason why this is happening unless we have something to play with. – Bart Apr 04 '16 at 18:02
  • @Bart It is clear now? – questionhang Apr 05 '16 at 12:40

1 Answers1

0

However, after we specify a dpi value in pl.savefig and save the figure, the details are lost.

The details aren't lost if you save the figure as pdf or svg, they are vector formats. Just try opening one of them in e.g. Inkscape, and you can select or edit every individual line segment.

The difference between zooming in a Matplotlib window or a saved figure is that the line width isn't re-scaled when you zoom in e.g. the saved PDF (which of course is a good thing).

After we save the figure, can we display it and adjust it like pl.show()

If that's what you want, why not simply re-run your Python script?

Bart
  • 9,825
  • 5
  • 47
  • 73
  • For me nothing has changed. 1) PNG is a raster format so you indeed loose information. 2) PDF/SVG are vector formats; the info is there, but you can't expect (and really don't want) the line widths to scale when you zoom. – Bart Apr 06 '16 at 14:49
  • Is it possible we can display a saved figure like Fig.1 instead of Fig.2 and Fig.3? – questionhang Apr 06 '16 at 15:08