6
$\begingroup$

It seems that having Placed inside Plot breaks the ImageSize specification:

cm = 72/2.54;
plt = 
  LogLogPlot[Exp[x], {x, 1, 3}, 
   ImageSize -> 12 cm,
   AspectRatio -> 0.73, 
   Frame -> True,
   PlotLegends -> 
     Placed[
       LineLegend[{"test"}, 
         LegendMarkers -> Automatic, LegendFunction -> Framed, LegendMargins -> 5], 
       {Right, Top}]];
Export["test.eps", plt]

Once I remove the Placed directive, it works better. That may be because, without Placed, the ImageSize includes the legend (however this includes a relatively huge space between the end of the legend and what mathematica thinks to be the end of the plot, see picture below), but once I place the legend somewhere else, the same size is retained rather than determined again. Is there any way to work around this so that the example above is really 12 cm in size?

To illustrate, this is the eps produced by the code. The crosshair shows where 12 cm is in reality:

<code>enter code here</code>

When I omit the Legend completely, I get size as wanted: enter image description here

and when I use Legend without placed: enter image description here

$\endgroup$
  • $\begingroup$ worked for me (MMA10.4, Linux) $\endgroup$ – Sumit May 8 '16 at 7:20
  • 1
    $\begingroup$ Could you expand on what "works" or doesn't work? Exporting works in both cases as far as producing a file, so what exactly doesn't work for you? $\endgroup$ – MarcoB May 10 '16 at 16:12
  • $\begingroup$ @MarcoB I added some pictures that show the problem. The problem is in the size of the resulting plot. Without a legend, the size of the plot is ok, with legend, there is unwanted space between the legend to the right and the 12 cm margin. And when Placed is used to move the legend inside the plot, the margin between the end of the plot and the 12 cm rises as Mathematica does not recalculate some margins probably. $\endgroup$ – leosenko May 10 '16 at 19:59

Your Answer

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

Browse other questions tagged or ask your own question.