4
$\begingroup$

I'm trying to export a simple plot like this one

myplot = 
 ListLogLogPlot[{{}, {}, {}}, PlotRange -> 10^{{1, 4}, {-10, 1}},
  PlotStyle -> {Gray, Blue, Orange},
  Frame -> True, Joined -> False,
  AspectRatio -> 0.65,
  FrameStyle -> 15, LabelStyle -> Directive[15, Black],
  FrameLabel -> {{Style["", Italic, 18], 
     Style["", 18]}, {Style["", 18], None}},
  Filling -> {4 -> {Top, Directive[Brown, Opacity[0.8]]}},
  ImageSize -> Large,
  PlotLegends -> {Placed[LineLegend[
      {Style["Case A", 12], Style["Case B", 12], 
       Style["Case C", 12]},
      LegendMarkers -> {Graphics[{Gray, Disk[{0, 0}, {3, 3}]}], 
        Graphics[{Blue, Disk[{0, 0}, {3, 3}]}], 
        Graphics[{Orange, Disk[{0, 0}, {3, 3}]}]},
      LegendFunction -> (Framed[#, RoundingRadius -> 5, 
          Background -> White] &),
      LegendLayout -> {"Column", 1}], {0.75, 0.15}]},
  PlotLabel -> 
   Text[Style[
     StringForm["Parameter X = `` and Parameter Y = ``", 1, 2], Black,
      17]]]

enter image description here

using the following line:

Export["Plot.png", myplot, ImageResolution -> 500];

Surprisingly, the PNG file has a problem with the tile:

enter image description here

that goes away if I remove the legend, which I need --of course:

enter image description here

What could be the issue? Thanks.

$\endgroup$
7
  • $\begingroup$ v13.1 on Win 11 work fine. $\endgroup$
    – cvgmt
    Commented Nov 23, 2022 at 0:37
  • $\begingroup$ Thanks, @cvgmt. Mine is v12.0.0.0 on macOS Ventura 13.0.1 $\endgroup$ Commented Nov 23, 2022 at 0:46
  • 1
    $\begingroup$ Yes, It also does not work on v11.3. But I found that the legend disapear when we using 13.1. $\endgroup$
    – cvgmt
    Commented Nov 23, 2022 at 0:50
  • $\begingroup$ Do you need an empty plot with a title and a legend? $\endgroup$
    – Syed
    Commented Nov 23, 2022 at 2:23
  • $\begingroup$ Thanks, @Syed. I’m not including the dataset for the sake of replicating the glitch $\endgroup$ Commented Nov 23, 2022 at 6:26

1 Answer 1

2
$\begingroup$

Slightly modify PlotLabel and then it works. Like so:

$Version

12.0.0 for Mac OS X x86 (64-bit)

We begin

SetDirectory@NotebookDirectory[]

and then

myplot = ListLogLogPlot[{{}, {}, {}}, 
  PlotRange -> 10^{{1, 4}, {-10, 1}}, 
  PlotStyle -> {Gray, Blue, Orange}, Frame -> True, Joined -> False, 
  AspectRatio -> 0.65, FrameStyle -> 15, 
  LabelStyle -> Directive[15, Black], 
  FrameLabel -> {{Style["", Italic, 18], 
     Style["", 18]}, {Style["", 18], None}}, 
  Filling -> {4 -> {Top, Directive[Brown, Opacity[0.8]]}}, 
  ImageSize -> Large, 
  PlotLegends -> {Placed[
     LineLegend[{Style["Case A", 12], Style["Case B", 12], 
       Style["Case C", 12]}, 
      LegendMarkers -> {Graphics[{Gray, Disk[{0, 0}, {3, 3}]}], 
        Graphics[{Blue, Disk[{0, 0}, {3, 3}]}], 
        Graphics[{Orange, Disk[{0, 0}, {3, 3}]}]}, 
      LegendFunction -> (Framed[#, RoundingRadius -> 5, 
          Background -> White] &), 
      LegendLayout -> {"Column", 1}], {0.75, 0.15}]}, 
  PlotLabel -> 
   Style[StringForm["Parameter X = `` and Parameter Y = ``", 1, 2], 
    Black, 17]]

Finally,

Export["Plot.png", myplot, ImageResolution -> 500];

plot

$\endgroup$

Your Answer

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

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