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$
  • $\begingroup$ No problem with version 12.1 on Windows 10 x64. $\endgroup$ – Alexey Popkov Mar 24 at 11:39
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)

| improve this answer | |
$\endgroup$
  • 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 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 at 21:02
  • $\begingroup$ There are still problems with numRaster = 2000 or numRaster = 1000 $\endgroup$ – Bob Hanlon Mar 21 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 at 18:53
  • $\begingroup$ From what I understood, this is internally already fixed, and might appear in a future update. $\endgroup$ – SHuisman Apr 2 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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