Skip to main content
Tweeted twitter.com/StackMma/status/931286469473456128
added more details, answering a comment
Source Link
ThunderBiggi
  • 1.2k
  • 6
  • 15

I have been trying to export an image (not the image below) with a legend to a pdf format for a publication (Mathematica 11.0.1). Unfortunately everything I have tried exports a version of the graphic where the legend is moved somewhere. I have tried looking into this (Szabolcs answer), this and have looked at the discussion here, but can't get it to work.

Here is a minimal example

data = Table[1/(1 - x^2), {x, 2, 11, 1}];
points = Table[x, {x, 2, 11, 1}];
pp = ListPlot[Transpose[{points, data}], PlotMarkers -> Automatic, 
  PlotLegends -> 
   Placed[PointLegend[{"Equation"}, 
     LegendFunction -> (Framed[#, Background -> LightBlue, 
         FrameStyle -> Directive[Black, Thick]] &), 
     LegendMarkerSize -> 12, 
     LegendLabel -> 
      Placed["Expr", Left, Rotate[Style[#, 14], 90 Degree] &], 
     LabelStyle -> Directive[12], LegendMargins -> 0], {0.19, 0.3}]]

LegEx

Exporting it with

Export["SomeDestination.pdf", pp, ImageResolution -> 600]

Leads to

enter image description here

(This is also the result of right-clicking on the graph in the notebook (the first provided image here) and selecting "Save Graphic as")

I have also tried doing

cm = 72/2.54;
image = Rasterize[Show[pp, ImageSize -> 126/10 cm], "Image", 
   ImageResolution -> 600];
Export["SomeDestination.pdf", 
 Show[image, ImageSize -> 126/10 cm], ImageResolution -> 600]

which gives

enter image description here

So we have three different images.

This is all done under

In[38]:= Options[$FrontEnd, {PrintingStyleEnvironment, 
  ScreenStyleEnvironment}]

Out[38]= {PrintingStyleEnvironment -> "Working", 
 ScreenStyleEnvironment -> "Working"}

All I want is to export as a pdf what I see in the notebook.

P.S. I would also be happy to see a solution where the image is not exported to a pdf, but to any other format.

I have been trying to export an image (not the image below) with a legend to a pdf format for a publication (Mathematica 11.0.1). Unfortunately everything I have tried exports a version of the graphic where the legend is moved somewhere. I have tried looking into this (Szabolcs answer), this and have looked at the discussion here, but can't get it to work.

Here is a minimal example

data = Table[1/(1 - x^2), {x, 2, 11, 1}];
points = Table[x, {x, 2, 11, 1}];
pp = ListPlot[Transpose[{points, data}], PlotMarkers -> Automatic, 
  PlotLegends -> 
   Placed[PointLegend[{"Equation"}, 
     LegendFunction -> (Framed[#, Background -> LightBlue, 
         FrameStyle -> Directive[Black, Thick]] &), 
     LegendMarkerSize -> 12, 
     LegendLabel -> 
      Placed["Expr", Left, Rotate[Style[#, 14], 90 Degree] &], 
     LabelStyle -> Directive[12], LegendMargins -> 0], {0.19, 0.3}]]

LegEx

Exporting it with

Export["SomeDestination.pdf", pp, ImageResolution -> 600]

Leads to

enter image description here

I have also tried doing

cm = 72/2.54;
image = Rasterize[Show[pp, ImageSize -> 126/10 cm], "Image", 
   ImageResolution -> 600];
Export["SomeDestination.pdf", 
 Show[image, ImageSize -> 126/10 cm], ImageResolution -> 600]

which gives

enter image description here

So we have three different images.

This is all done under

In[38]:= Options[$FrontEnd, {PrintingStyleEnvironment, 
  ScreenStyleEnvironment}]

Out[38]= {PrintingStyleEnvironment -> "Working", 
 ScreenStyleEnvironment -> "Working"}

All I want is to export as a pdf what I see in the notebook.

P.S. I would also be happy to see a solution where the image is not exported to a pdf, but to any other format.

I have been trying to export an image (not the image below) with a legend to a pdf format for a publication (Mathematica 11.0.1). Unfortunately everything I have tried exports a version of the graphic where the legend is moved somewhere. I have tried looking into this (Szabolcs answer), this and have looked at the discussion here, but can't get it to work.

Here is a minimal example

data = Table[1/(1 - x^2), {x, 2, 11, 1}];
points = Table[x, {x, 2, 11, 1}];
pp = ListPlot[Transpose[{points, data}], PlotMarkers -> Automatic, 
  PlotLegends -> 
   Placed[PointLegend[{"Equation"}, 
     LegendFunction -> (Framed[#, Background -> LightBlue, 
         FrameStyle -> Directive[Black, Thick]] &), 
     LegendMarkerSize -> 12, 
     LegendLabel -> 
      Placed["Expr", Left, Rotate[Style[#, 14], 90 Degree] &], 
     LabelStyle -> Directive[12], LegendMargins -> 0], {0.19, 0.3}]]

LegEx

Exporting it with

Export["SomeDestination.pdf", pp, ImageResolution -> 600]

Leads to

enter image description here

(This is also the result of right-clicking on the graph in the notebook (the first provided image here) and selecting "Save Graphic as")

I have also tried doing

cm = 72/2.54;
image = Rasterize[Show[pp, ImageSize -> 126/10 cm], "Image", 
   ImageResolution -> 600];
Export["SomeDestination.pdf", 
 Show[image, ImageSize -> 126/10 cm], ImageResolution -> 600]

which gives

enter image description here

So we have three different images.

This is all done under

In[38]:= Options[$FrontEnd, {PrintingStyleEnvironment, 
  ScreenStyleEnvironment}]

Out[38]= {PrintingStyleEnvironment -> "Working", 
 ScreenStyleEnvironment -> "Working"}

All I want is to export as a pdf what I see in the notebook.

P.S. I would also be happy to see a solution where the image is not exported to a pdf, but to any other format.

edited tags
Link
ThunderBiggi
  • 1.2k
  • 6
  • 15
added mathematica version
Source Link
ThunderBiggi
  • 1.2k
  • 6
  • 15

I have been trying to export an image (not the image below) with a legend to a pdf format for a publication (Mathematica 11.0.1). Unfortunately everything I have tried exports a version of the graphic where the legend is moved somewhere. I have tried looking into this (Szabolcs answer), this and have looked at the discussion here, but can't get it to work.

Here is a minimal example

data = Table[1/(1 - x^2), {x, 2, 11, 1}];
points = Table[x, {x, 2, 11, 1}];
pp = ListPlot[Transpose[{points, data}], PlotMarkers -> Automatic, 
  PlotLegends -> 
   Placed[PointLegend[{"Equation"}, 
     LegendFunction -> (Framed[#, Background -> LightBlue, 
         FrameStyle -> Directive[Black, Thick]] &), 
     LegendMarkerSize -> 12, 
     LegendLabel -> 
      Placed["Expr", Left, Rotate[Style[#, 14], 90 Degree] &], 
     LabelStyle -> Directive[12], LegendMargins -> 0], {0.19, 0.3}]]

LegEx

Exporting it with

Export["SomeDestination.pdf", pp, ImageResolution -> 600]

Leads to

enter image description here

I have also tried doing

cm = 72/2.54;
image = Rasterize[Show[pp, ImageSize -> 126/10 cm], "Image", 
   ImageResolution -> 600];
Export["SomeDestination.pdf", 
 Show[image, ImageSize -> 126/10 cm], ImageResolution -> 600]

which gives

enter image description here

So we have three different images.

This is all done under

In[38]:= Options[$FrontEnd, {PrintingStyleEnvironment, 
  ScreenStyleEnvironment}]

Out[38]= {PrintingStyleEnvironment -> "Working", 
 ScreenStyleEnvironment -> "Working"}

All I want is to export as a pdf what I see in the notebook.

P.S. I would also be happy to see a solution where the image is not exported to a pdf, but to any other format.

I have been trying to export an image (not the image below) with a legend to a pdf format for a publication. Unfortunately everything I have tried exports a version of the graphic where the legend is moved somewhere. I have tried looking into this (Szabolcs answer), this and have looked at the discussion here, but can't get it to work.

Here is a minimal example

data = Table[1/(1 - x^2), {x, 2, 11, 1}];
points = Table[x, {x, 2, 11, 1}];
pp = ListPlot[Transpose[{points, data}], PlotMarkers -> Automatic, 
  PlotLegends -> 
   Placed[PointLegend[{"Equation"}, 
     LegendFunction -> (Framed[#, Background -> LightBlue, 
         FrameStyle -> Directive[Black, Thick]] &), 
     LegendMarkerSize -> 12, 
     LegendLabel -> 
      Placed["Expr", Left, Rotate[Style[#, 14], 90 Degree] &], 
     LabelStyle -> Directive[12], LegendMargins -> 0], {0.19, 0.3}]]

LegEx

Exporting it with

Export["SomeDestination.pdf", pp, ImageResolution -> 600]

Leads to

enter image description here

I have also tried doing

cm = 72/2.54;
image = Rasterize[Show[pp, ImageSize -> 126/10 cm], "Image", 
   ImageResolution -> 600];
Export["SomeDestination.pdf", 
 Show[image, ImageSize -> 126/10 cm], ImageResolution -> 600]

which gives

enter image description here

So we have three different images.

This is all done under

In[38]:= Options[$FrontEnd, {PrintingStyleEnvironment, 
  ScreenStyleEnvironment}]

Out[38]= {PrintingStyleEnvironment -> "Working", 
 ScreenStyleEnvironment -> "Working"}

All I want is to export as a pdf what I see in the notebook.

P.S. I would also be happy to see a solution where the image is not exported to a pdf, but to any other format.

I have been trying to export an image (not the image below) with a legend to a pdf format for a publication (Mathematica 11.0.1). Unfortunately everything I have tried exports a version of the graphic where the legend is moved somewhere. I have tried looking into this (Szabolcs answer), this and have looked at the discussion here, but can't get it to work.

Here is a minimal example

data = Table[1/(1 - x^2), {x, 2, 11, 1}];
points = Table[x, {x, 2, 11, 1}];
pp = ListPlot[Transpose[{points, data}], PlotMarkers -> Automatic, 
  PlotLegends -> 
   Placed[PointLegend[{"Equation"}, 
     LegendFunction -> (Framed[#, Background -> LightBlue, 
         FrameStyle -> Directive[Black, Thick]] &), 
     LegendMarkerSize -> 12, 
     LegendLabel -> 
      Placed["Expr", Left, Rotate[Style[#, 14], 90 Degree] &], 
     LabelStyle -> Directive[12], LegendMargins -> 0], {0.19, 0.3}]]

LegEx

Exporting it with

Export["SomeDestination.pdf", pp, ImageResolution -> 600]

Leads to

enter image description here

I have also tried doing

cm = 72/2.54;
image = Rasterize[Show[pp, ImageSize -> 126/10 cm], "Image", 
   ImageResolution -> 600];
Export["SomeDestination.pdf", 
 Show[image, ImageSize -> 126/10 cm], ImageResolution -> 600]

which gives

enter image description here

So we have three different images.

This is all done under

In[38]:= Options[$FrontEnd, {PrintingStyleEnvironment, 
  ScreenStyleEnvironment}]

Out[38]= {PrintingStyleEnvironment -> "Working", 
 ScreenStyleEnvironment -> "Working"}

All I want is to export as a pdf what I see in the notebook.

P.S. I would also be happy to see a solution where the image is not exported to a pdf, but to any other format.

Source Link
ThunderBiggi
  • 1.2k
  • 6
  • 15
Loading