3
$\begingroup$

I have upgraded to 12.1 (on OSX Catalina 10.15.3) and am noticing some odd behaviour with Rasterize.

If I use a high number of rasters when rasterising a ListDensityPlot the text on the axes and plot label gets scrambled. This (1) does not occur in 12.1 when rasterising a ListPlot, and (2) did not occur when the exact same code was run under 12.0.

Ultimately I am rasterising a bunch of plots and saving them out as eps format. However, here is a much more minimal piece of code which demonstrates the error.

lpd = ListDensityPlot[{{1, 1, 1, 1}, {1, 2, 1, 2}, {1, 1, 3, 1}, {1, 2, 1, 4}}, Mesh -> All, PlotLabel -> "HELLO WORLD", FrameLabel -> {"HELLO WORLD", "HELLO WORLD"}];
lp = ListPlot[Prime[Range[25]], PlotLabel -> "HELLO WORLD", Frame -> True, FrameLabel -> {"HELLO WORLD", "HELLO WORLD"}];

numRaster = 4000;
Rasterize[lp, RasterSize -> numRaster]
Rasterize[lpd, RasterSize -> numRaster]

This gives the following images. Note if numRaster = Automatic the images look fine.

So yes, I understand that I can set numRaster = Automatic, but I am just puzzled by code working in 12.0 and suddenly breaking 12.1.

enter image description here

$\endgroup$
1
  • $\begingroup$ No problem with version 12.1 on Windows 10 x64. $\endgroup$ Mar 24, 2020 at 11:39

1 Answer 1

1
$\begingroup$

I also have encountered this bug in 12.1. It has been reported to WRI already. It can be mitigated by choosing the RasterSize an integer multiple of the ImageSize:

lpd = ListDensityPlot[{{1, 1, 1, 1}, {1, 2, 1, 2}, {1, 1, 3, 1}, {1, 
     2, 1, 4}}, Mesh -> All, PlotLabel -> "HELLO WORLD", 
   FrameLabel -> {"HELLO WORLD", "HELLO WORLD"}, ImageSize -> 500];
lp = ListPlot[Prime[Range[25]], PlotLabel -> "HELLO WORLD", 
   Frame -> True, FrameLabel -> {"HELLO WORLD", "HELLO WORLD"}, 
   ImageSize -> 500];

numRaster = 4000;
Rasterize[lp, RasterSize -> numRaster]
Rasterize[lpd, RasterSize -> numRaster]

which works as it should. (at least on Mac)

$\endgroup$
5
  • 1
    $\begingroup$ On my Mac with v12.1 and using your code, there are still problems with the labels for the ListDensityPlot. $\endgroup$
    – Bob Hanlon
    Mar 21, 2020 at 18:43
  • $\begingroup$ Have you tried RasterSize 1000? or 2000? Depending on your setup the maximum 'drawing buffer' is 4096*4096 or 8192*8192 (including HiDPI stuff and so on). $\endgroup$
    – SHuisman
    Mar 21, 2020 at 21:02
  • $\begingroup$ There are still problems with numRaster = 2000 or numRaster = 1000 $\endgroup$
    – Bob Hanlon
    Mar 21, 2020 at 22:42
  • $\begingroup$ This seems to be a good workaround for me. My issue was during export, as I assume Rasterize is called at some point during that process. With ImageSize -> 500 and Export["~/Desktop/test.png", plot, RasterSize -> 4000, ImageResolution -> 300], I got the correct output. $\endgroup$
    – MassDefect
    Apr 2, 2020 at 18:53
  • $\begingroup$ From what I understood, this is internally already fixed, and might appear in a future update. $\endgroup$
    – SHuisman
    Apr 2, 2020 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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