From a previous post Remove artifact of PDF images I am using the following function:
rasterizeBackground[g_, res_: 450] :=
ReplacePart[
g, # -> rasterizeBackground[Extract[g, #], res] & /@
Position[g, Graphics[__]]]
Which rasterize the image and leaves as vector format the axis and its ticks labels. However, if the plot has a legend like in the following plot:
(*some random data*)
data21fps = 200 {#1 #2, Sin[#1 + #2]^2} & @@@ RandomReal[{0, 1}, {100000, 2}];
f[x_] := x /. {NumberForm[y_, {w_, z_}] :> ScientificForm[y, 2]}
f21fps = Show[SmoothDensityHistogram[data21fps,
PlotRange -> {{0, 200}, {0, 200}},
ColorFunction -> "SunsetColors",
FrameLabel -> {Text[
Style["t2-t1", FontSize -> 14, Italic],
FormatType -> StandardForm],
Text[Style["t1", FontSize -> 14,
Italic], FormatType -> StandardForm]},
PlotLabel -> "FPS", LabelStyle -> {FontFamily -> "Times", 14},
PlotLegends ->
BarLegend[Automatic, LegendFunction -> f,
LegendMarkerSize -> 368]
, Mesh -> 0
], Plot[x, {x, 0, 200}], ImageSize -> 400, PlotRangePadding -> 0]
Export["f21fps.pdf",f21fps];
In this case, the legend ticks in the PDF file does not look as bright or clear as the ticks of the frame, probably because they have been rasterized like the image of the plot. Is it possible to leave the legend ticks in vector format?
Thank you very much for your help
rasterizeBackground[]that I use. Sorry for that. – user1993416 Aug 13 '17 at 16:37TicksStyle,FrameStyleetc. do all work as intended. You may refer to the documentation of Graphics for a full list. – Lukas Lang Aug 13 '17 at 17:24LabelStyle -> {FontFamily -> "Times", 14, Directive[Black, AbsoluteThickness[2], Opacity[1]]}makes black all ticks labels included the Legend. – user1993416 Aug 13 '17 at 17:38rasterizeBackgroundfunction does not work and leaves the artifacts (white lines) in the TeX file. You were right, unfortunately, seems not so easy to change the color and opacity of the legend labels. – user1993416 Aug 13 '17 at 17:52rasterizeBackground[]does not reduce the size of the PDF file and leave the white lines. I have made load the definitions again and repeat the same steps but does not rasterize the image. – user1993416 Aug 13 '17 at 18:02rasterizeBackgroundworks but taking off the PlotLegend option. If I include PlotLegend none of the two definitions work rasterizing the image. – user1993416 Aug 13 '17 at 18:21