Let's consider the following example

S0 = Plot[Sin[x], {x, -10, 10}, Frame -> True, ImageSize -> 550]

First we export the plot in a JPEG format

E1 = Export["tst.jpg", S0];

enter image description here

Then we export the same plot with more resolution

E2 = Export["tst2.jpg", S0, ImageResolution -> 400];

enter image description here

Here we observe two unpleasant things:

(a). The lines of the axes are light gray instead of black.

(b). The ticks on the axes are almost invisible or absent.

Is there a way to eliminate these drawbacks without losing the desired resolution (400)?

I am using v9.0 in Win XP Pro SP3.

The solution provided here previous post does not work in my case.

  • $\begingroup$ Also, IMO I'd export that as a PDF vector format, unless you need it as a raster. $\endgroup$ – Quantum_Oli Mar 10 '16 at 13:25
  • $\begingroup$ @Quantum_Oli I need the plot in JPEG format without rasterizing it. $\endgroup$ – Vaggelis_Z Mar 10 '16 at 13:31
  • $\begingroup$ @Vaggelis_Z - if you export as a jpeg you are rasterizing it $\endgroup$ – Jason B. Mar 10 '16 at 13:32
  • $\begingroup$ Hence the ImageResolution option $\endgroup$ – Quantum_Oli Mar 10 '16 at 13:33
  • $\begingroup$ @Quantum_Oli, I would agree that it's a duplicate, but in this case Jens's solution looks atrocious: i.stack.imgur.com/XETmZ.png $\endgroup$ – Jason B. Mar 10 '16 at 13:34

I've run into this problem before as well, and my solution is to use the CustomTicks package, part of the SciDraw package. The rest of the package could be great, but I only ever have used CustomTicks, and the number of times I've used it I wish I could buy the authors a beer. Anyway, try this

S0 = Plot[Sin[x], {x, -10, 10}, Frame -> True, ImageSize -> 550, 
  FrameTicks -> {{LinTicks, StripTickLabels@LinTicks}, {LinTicks, 
Export["tst3.jpg", S0, ImageResolution -> 400]

enter image description here

  • $\begingroup$ First you download the latest version of SciDraw and then you extract the .zip file. Next? Where do you place the extracted files? $\endgroup$ – Vaggelis_Z Mar 10 '16 at 13:46
  • $\begingroup$ I believe you can place the folder CustomTicks in any of the directories listed when you evaluate $Path. For me, that could be "/home/jason/.Mathematica/Applications". I personally have a custom packages directory that I have appended to the path, which you could do easily enough $\endgroup$ – Jason B. Mar 10 '16 at 13:49
  • $\begingroup$ If I place them in C:\Program Files\Wolfram Research\Mathematica\9.0\AddOns\ExtraPackages, will it be OK? $\endgroup$ – Vaggelis_Z Mar 10 '16 at 13:52
  • $\begingroup$ That sounds about right $\endgroup$ – Jason B. Mar 10 '16 at 13:52
  • $\begingroup$ It works but again the bounding box and the ticks are light gray and hardly visible. I want them to remain black. $\endgroup$ – Vaggelis_Z Mar 10 '16 at 13:55

If you're willing to specify ImagePadding in the first place then we can rasterise the plot graphics and insert it back into still vector axes.

    S0 = Plot[Sin[x], {x, -10, 10}, Frame -> True, ImageSize -> 550,
     ImagePadding -> {{30, 10}, {30, 10}}]

    fig = Rasterize[Show[S0, Frame -> False, Axes -> False], 
      ImageResolution -> 100, Background -> None]
    axes = ImportString[ExportString[Graphics[{}, Options[S0]], "EPS"]]

    combined = Show[axes, 
      Epilog -> Inset[fig, {0, 0}, {0, 0}, ImageDimensions[axes]]];

    Export["test.pdf", combined]

enter image description here

This will allow you to export ListPlot with lots of points! The PDF of the below 10000 points is 60kb

enter image description here

EDIT: Why do I have to specify ImagePadding?

If I don't then the Inset graphics won't be in the correct place. I can't find a way to avoid this, specifically why does

   AbsoluteOptions[S0, ImagePadding]

throw error messages about Ticks? And why does it not return a value when ImagePadding -> Automatic?


Not the answer you're looking for? Browse other questions tagged or ask your own question.