0
$\begingroup$

I have Mathematica 13.1 on Windows 10. The problem is not present on Mathematica 12.1!

I try to export the following plot:

plot = Show[
  ListLogLogPlot[{Table[{x, 10^-12}, {x, 0.1, 5, 1}]}, Joined -> True,
    PlotStyle -> {{Thick, Gray}}, Frame -> True, 
   FrameLabel -> {"\!\(\*SubscriptBox[\(m\), \(S\)]\) [GeV]" , 
     "\!\(\*SuperscriptBox[\(\[Theta]\), \(2\)]\)"}, 
   FrameStyle -> Directive[Black, 23], ImageSize -> Large, 
   PlotRange -> {{0.2, 5}, {10^-14, 10^-4}}, 
   PlotLabel -> Style[Row[{"Caption "}], 18, Black], 
   Filling -> {1 -> {True, Directive[Gray, Opacity[0.3]]}}], 
  Graphics[{Text[Style["Excluded", 24, Black], Scaled[{0.2, 0.9}]], 
    Text[Style[Row[{"\[Tau] = 1 ps"}], 15, Lighter@Gray], 
     Scaled[{0.6, 0.74}], Left, {3, -0.4}], 
    Text[Style["\[Tau] = 100 ps", 15, Lighter@Gray], 
     Scaled[{0.6, 0.53}], Left, {3, -0.4}], 
    Text[Style["\[Tau] = \!\(\*SuperscriptBox[\(10\), \(4\)]\) ps", 
      15, Lighter@Gray], Scaled[{0.6, 0.34}], Left, {3, -0.4}], 
    Text[Style["\[Tau]=\!\(\*SuperscriptBox[\(10\), \(6\)]\) ps", 15, 
      Lighter@Gray], Scaled[{0.6, 0.15}], Left, {3, -0.4}]}]]
Export[FileNameJoin[{NotebookDirectory[], "plot.pdf"}], plot]

This is how it looks in Mathematica (left) and when opening the exported .pdf (right):

enter image description here

In particular, all the graphics with rotated text is not present. Could you please tell me how to fix this issue?

Edit

The problem is in the text rotation. Say, for

Text[Style["\[Tau] = \!\(\*SuperscriptBox[\(10\), \(4\)]\) ps", 
      15, Lighter@Gray], Scaled[{0.6, 0.34}], Left, {3, -0.4}]

the text is displayed properly if removing Left, {3, -0.4}. However, the rotation is crucial for me.

$\endgroup$
9
  • 1
    $\begingroup$ The offending command is the direction vector. According to the help, there are only -1,0,1 allowed. $\endgroup$ Jul 26 at 11:53
  • $\begingroup$ @DanielHuber : is there any alternative to the rotation that I use? $\endgroup$ Jul 26 at 11:58
  • $\begingroup$ @DanielHuber : also, it is interesting that it works on 12.1. $\endgroup$ Jul 26 at 12:00
  • 2
    $\begingroup$ An alternative is Rotate[Text[...], phi], where Text is without the direction vector and the position needs adjusting. $\endgroup$ Jul 26 at 12:11
  • 1
    $\begingroup$ It's weird.. I tried to used the string "test" instead of "\Tau = 100 ps" made the font larger and then it shows the string. Seems to me as a bug somewhere. Text[Style["test", 25, Lighter@Gray], Scaled[{0.6, 0.53}], Left, {3, -0.4}] e.g. shows in the PDF $\endgroup$
    – Lou
    Jul 27 at 16:10

1 Answer 1

-1
$\begingroup$

There is a simple workaround. One can first rasterize the image:

plotRast = Rasterize[plot, RasterSize -> 800, ImageSize -> Large]

Now play with the RasterSize value to achieve the desired quality and export the rasterized file exactly as you did. The obtained PDF file is shown in the image below:

enter image description here

Have fun!

$\endgroup$
1
  • $\begingroup$ Thanks, but then there is no difference as compared to exporting in .png. I would like to preserve the vector form. $\endgroup$ Jul 26 at 11:15

Your Answer

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

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