1

I have generated some basic scatter and line plots that I want to embed in my paper. I am using matplotlib, which gives me flexibility over the format exported. I like the SVG approach for its convenient zooming behavior, but it comes with the problem of the resulting PDF size (all the data is actually in the file, even when the points are overlapping). I have a few questions:

  1. Should I embed the plots as a vector or as a raster graphic? Why?
  2. If going for the SVG way, is it justified to only present a sample of the data? If so, should I state in the paper that the data shown is just a sample?
  3. If going for the raster approach, is JPG enough or should I use a lossless format?

Thank you!

Edit: as noted by @DCTLib, there also is a fourth option to generate the plot directly in LaTex - should I think of it? Is it standard?

6
  • 1
    This is a technical question, not one about academia.
    – Buffy
    Commented Apr 18, 2023 at 13:48
  • 5
    This paper will be published? If so, follow the guidelines of the journal.
    – GEdgar
    Commented Apr 18, 2023 at 13:48
  • 5
    JPEG is lossy. Don't use JPEG for graphs unless a compelling reason dictates. While one can crank up the quality setting enough to show the nice dots, there is no guarantee that the next parsing/rendering software won't decide the proper quality setting for you.
    – fraxinus
    Commented Apr 18, 2023 at 13:58
  • 4
    For graphs, PNG is normally better than JPG if a pixel image should be used. If the paper is written in LaTeX, there is also the possibility to export LaTeX code directly from Matplotlib.
    – DCTLib
    Commented Apr 18, 2023 at 14:00
  • 5
    Personally I export my figures as pdfs, and rasterise them only if they're really heavy. But there's no one correct way to do it. Commented Apr 18, 2023 at 14:31

1 Answer 1

1

When deciding whether to embed plots as a vector or raster graphic, there are a few factors to consider:

  1. Vector graphics (e.g. SVG) are resolution-independent, meaning they can be zoomed in without losing quality. Raster graphics (e.g. JPG, PNG) have a fixed resolution and can become pixelated when zoomed in.

  2. Vector graphics can be smaller in file size than raster graphics, especially for complex images with many data points or lines.

  3. Raster graphics can be easier to manipulate and edit using image editing software like Photoshop or GIMP.

    Given these factors, if you need to present detailed plots that require zooming in, vector graphics may be a better option. However, if the plots are relatively simple and don't require zooming in, raster graphics may be sufficient.

If you decide to go with the SVG approach, it may be acceptable to show a sample of the data if the complete data set is too large to display clearly. In this case, it's a good idea to state in the paper that the data shown is a sample, and to explain how the sample was selected.

Otherwise, if you decide to go with the raster approach, whether JPG is sufficient depends on the level of detail in your plots. If your plots have a lot of fine detail, a lossless format like PNG may be better to avoid compression artifacts. If your plots are relatively simple, JPG may be sufficient and have a smaller file size.

2
  • 3
    I find JPEG wholly unsuitable for almost any plot due to compression artifacts, regardless of the level of detail. JPEG was designed to work well for fairly noisy and smoothly varying images like photographs. It's not good at compressing high-contrast images that have geometric figures with clear boundaries, which any plot with an axis has. Even a simple scatter plot with few points will have noticeable artifact "smudges" in JPEG form. These are plots intended for human interpretation, they won't be so numerous as to make the file size savings of a JPEG very significant. Commented Apr 18, 2023 at 15:39
  • 2
    Thank you, cryptoShark007. That's a nice answer, but I can't help feeling it looks very ChatGPT-ish; you don't normally use Gimp or Photoshop to manipulate plots to embed in a publication. Also, your answer doesn't really answer my question - it only lists a couple of widely known facts about the image formats and leaves the decision to me Commented Apr 18, 2023 at 16:03

Not the answer you're looking for? Browse other questions tagged .