Hi,
at first I thought Heike's solution with "TransparentPolygonMesh" ->
True was going to make my day. But unfortunately, when I export the
plot as PDF on Mac, it still shows the ugly mesh lines. So instead of
this solution, I modified another approach that I had settled on:
rasterContourPlot[f_, rx_, ry_, opts : OptionsPattern[]] :=
Module[{img, cont, plotRangeRule, contourOptions, frameOptions},
contourOptions =
Join[FilterRules[{opts},
FilterRules[Options[ContourPlot],
Except[{Background, PlotRangePadding, Frame,
Axes}]]], {PlotRangePadding -> None, Frame -> None,
Axes -> None}];
cont = ContourPlot[f, rx, ry,
Evaluate@Apply[Sequence, contourOptions]];
img = Rasterize[Graphics[
GraphicsComplex[cont[[1, 1]], cont[[1, 2, 1]]],
PlotRangePadding -> None, ImagePadding -> None],
ImageSize -> 2 ((ImageSize /. {opts}) /. {ImageSize ->
CurrentValue[ImageSize]})];
plotRangeRule = FilterRules[AbsoluteOptions[cont], PlotRange];
frameOptions = Join[FilterRules[{opts},
FilterRules[Options[Graphics],
Except[{PlotRangeClipping, PlotRange}]]],
{plotRangeRule, Frame -> True, PlotRangeClipping -> True}];
Show[Graphics[{{FaceForm[], EdgeForm[],
Apply[Rectangle, Transpose[PlotRange /. plotRangeRule]]},
Inset[Show[SetAlphaChannel[img, "ShadingOpacity" /. {opts}
/. {"ShadingOpacity" -> 1}], AspectRatio -> Full],
Scaled[{0, 0}], Scaled[{0, 0}], Scaled[{1, 1}]]},
PlotRangePadding -> None],
Graphics[GraphicsComplex[cont[[1, 1]], cont[[1, 2, 2]]],
PlotRangePadding -> None, ImagePadding -> None],
Evaluate@Apply[Sequence, frameOptions]]
]
Now I'm using this modified contour plot function with grid lines and
a prolog that display a blue disk behind the plot:
rasterContourPlot[x y^2 + 2, {x, -2, 2}, {y, -2, 2},
PlotRange -> {-10, 10}, GridLines -> Automatic, Contours -> 15,
"ShadingOpacity" -> .5, ImageSize -> 600,
Prolog -> {Blue, Disk[{1, 1.5}, 1]}]
The function has one new option that the standard contour plot doesn't
have: "ShadingOpacity" - that's what determines the opacity of the
contour shading. To implement this opacity, I convert the shading to
an image and then apply an alpha channel. The image is also immune to
the mesh lines artifacts that plagued the original exported PDF.
Jens