7
$\begingroup$

During the debugging of my previous question (somewhat related), I encountered this strange behaviour: when the global option Antialiasing is set to True in Option Inspector, the following code gives non-antialiased plots (observe e.g. frames):

GraphicsRow@{
  ListContourPlot[
   Table[Sin[i + j^2], {i, 0, 2, 0.05}, {j, 1.2, 2, 0.05}], 
   ColorFunction -> ColorData["AvocadoColors"], Contours -> 10, 
   Mesh -> False, ImageSize -> 400],
  ListDensityPlot[
   Table[Sin[i + j^2], {i, 0, 2, 0.05}, {j, 1.2, 2, 0.05}], 
   ColorFunction -> ColorData["AvocadoColors"], Mesh -> False, 
   ImageSize -> 400]
  }

Mathematica graphics

The next input is from the same notebook, same session, the only difference is that GraphicsRow only contains one plot object. Result is antialiased (visible polygon edges are of no concern here, see other post).

GraphicsRow@{ListContourPlot[
   Table[Sin[i + j^2], {i, 0, 2, 0.05}, {j, 1.2, 2, 0.05}], 
   ColorFunction -> ColorData["AvocadoColors"], Contours -> 10, 
   Mesh -> False, ImageSize -> 400], ""}

Mathematica graphics

Question

Is it a bug of GraphicsRow?

$\endgroup$
  • $\begingroup$ What platform are you using? $\endgroup$ – ragfield Jan 20 '12 at 17:52
  • $\begingroup$ @ragfield FWIW I see the same behavior on mma7/win7. $\endgroup$ – Mr.Wizard Jan 20 '12 at 18:22
  • $\begingroup$ I use Win7/Mma8. I should add that on the OSX/Mma8, while non-antialiasing is not that obvious due to some screen smoothing, still the two GraphicsRow objects produces different outputs. The first two plots seem to be non-antialiased, the second has the visible polygon edges. $\endgroup$ – István Zachar Jan 20 '12 at 21:41
5
$\begingroup$

GraphicsRow puts both plots into one GraphicsBox, which means they have to be rendered together. Since the DensityPlot contains VertexColors it has to be rendered (on some platforms) using the 3D graphics renderer, whose support for Antialiasing is highly hardware dependent.

ContourPlot output normally renders with a 2D graphics engine. DensityPlot normally renders with a 3D graphics engine. When you group the two together (via GraphicsRow in this case) it forces them both to render with the 3D graphics engine, and that causes the ContourPlot to have a slightly different appearance.

Take a look at this example, containing only the ContourPlot. This code forces the ContourPlot to be drawn with a 2D renderer (in my case Quartz, since I'm using a Mac) in one window and a 3D renderer (OpenGL) in another window. Observer the difference in appearance (at full size):

g = ListContourPlot[
   Table[Sin[i + j^2], {i, 0, 2, 0.05}, {j, 1.2, 2, 0.05}], 
   ColorFunction -> ColorData["AvocadoColors"], Contours -> 10, 
   Mesh -> False, ImageSize -> 400];

CreateDocument[g, CacheGraphics -> False, 
  "NotebookRenderingEngine" -> "Quartz"];

CreateDocument[g, CacheGraphics -> False, 
  "NotebookRenderingEngine" -> "OpenGL"];

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Could you please provide some detail of why the rendering is substantially different in GraphicsBox? $\endgroup$ – Mr.Wizard Jan 20 '12 at 18:21
  • $\begingroup$ Just interested to know what the differences are - my eyes are struggling to see any difference between the images on my machine. $\endgroup$ – cormullion Jan 20 '12 at 20:04
  • $\begingroup$ If you view the image at full size (right-click > Open in New Window) you can tell the one on the left (Quartz) is antialiased, while the one on the right (OpenGL) is not. Since it has been scaled down to fit in the webpage they both appear antialiased. $\endgroup$ – ragfield Jan 20 '12 at 20:33
  • $\begingroup$ My Windows WM 11.3 does not recognized the option NotebookRenderingEngine option.. Any idea why? $\endgroup$ – Jose Enrique Calderon Feb 17 '19 at 21:52
  • $\begingroup$ @JoseEnriqueCalderon By "not recognized" do you mean the syntax highlighting is red, or do you mean it doesn't appear to have any effect? What are you trying to accomplish? This is not a documented option and is therefore subject to change without notice. I only used it here to demonstrate the difference between the antialiasing behavior using 2D drawing vs. 3D drawing. This option probably wouldn't be useful for actually trying to accomplish anything. $\endgroup$ – ragfield Feb 18 '19 at 22:12

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.