0
$\begingroup$

I generate some density plot using the following code:

DensityPlot[
 Log10[distr2[1, \[Theta]B, EB]], {\[Theta]B, 7*10^-4, 0.2}, {EB, 2, 
  350}, ScalingFunctions -> {"Log", "Log"}, AspectRatio -> 0.7, 
 PlotRange -> {{7*10^-4, 0.2}, All, {-2, 2}}, ImageSize -> Large, 
 FrameLabel -> {"\!\(\*SubscriptBox[\(\[Theta]\), \(a\)]\) [rad]" , 
   "\!\(\*SubscriptBox[\(E\), \(a\)]\) [GeV]"}, Frame -> True, 
 FrameStyle -> Directive[Black, 25], 
 PlotLegends -> 
  Placed[BarLegend[{Automatic(*ColorData["RedBlueTones"]*), {-2, 2}}, 
    LegendMarkerSize -> 340, 
    LegendLabel -> 
     Placed["\!\(\*SubscriptBox[\(Log\), \
\(10\)]\)[\!\(\*SubscriptBox[\(f\), \(ALP\)]\)]", Bottom], 
    LabelStyle -> {FontSize -> 22}, 
    Method -> {FrameStyle -> Black, AxesStyle -> None, 
      TicksStyle -> Black}], Bottom], 
 PlotLabel -> 
  Style[Row[{"ALPs coupled to \[Gamma]. Primakov process. \
\!\(\*SubscriptBox[\(m\), \(a\)]\) = 1 GeV"}], 18, Black], 
 FrameTicks -> {{Automatic, Automatic}, {TicksPlotx, None}}]

Export[FileNameJoin[{NotebookDirectory[], 
   "plots/SensCalc/Double-Distr-ALPs.pdf"}], plot1]

In Mathematica and in Chrome/Edge web-browsers, as well as in Adobe Acrobat, it looks okay:

enter image description here

However, it is empty on Safari:

enter image description here

In addition, the size of the file is pretty large - around 1 Mb. Could you please tell me how to save the file without losing the quality of the plot but without the mentioned problems? I was thinking of rasterizing the plot itself but keeping the labels and legends vector, but I do not know whether it is possible at all in Mathematica.

The option "AllowRasterization" -> True is ugly. On the other hand, the option "AllowRasterization" -> False produces a light .pdf but with ugly rectangles and triangles (but who knows, maybe it is the only way...):

enter image description here

Edit

This is some example plot:

function[x_, y_] = 
  10^18 Cos[5*x] Sin[x] Exp[-((y^2*Cos[2*x]^4)/100)];
TicksPlotx = 
  Join[Flatten[
    Table[{i*10^j, ""}, {i, 2, 9, 1}, {j, -4, 0, 1}], {1, 
     2}], {{10^-3, 
     "\!\(\*SuperscriptBox[\(10\), \(-3\)]\)", {0.03, 0}}, {10^-2, 
     "\!\(\*SuperscriptBox[\(10\), \(-2\)]\)", {0.03, 0}}, {10^-1, 
     "\!\(\*SuperscriptBox[\(10\), \(-1\)]\)", {0.03, 0}}, {1, 1, 
     0.03}}];
plot1 = DensityPlot[
  Log10[function[x, y]], {x, 7*10^-4, 0.2}, {y, 2, 350}, 
  ScalingFunctions -> {"Log", "Log"}, AspectRatio -> 0.7, 
  PlotRange -> {{7*10^-4, 0.2}, All, {-6, 13}}, ImageSize -> Large, 
  FrameLabel -> {"\!\(\*SubscriptBox[\(\[Theta]\), \(a\)]\) [rad]" , 
    "\!\(\*SubscriptBox[\(E\), \(a\)]\) [GeV]"}, Frame -> True, 
  FrameStyle -> Directive[Black, 25], 
  PlotLegends -> 
   Placed[BarLegend[{Automatic(*ColorData[
      "RedBlueTones"]*), {-6, 13}}, LegendMarkerSize -> 340, 
     LegendLabel -> 
      Placed["\!\(\*SubscriptBox[\(Log\), \
\(10\)]\)[\!\(\*SubscriptBox[\(f\), \(ALP\)]\) [\!\(\*SuperscriptBox[\
\(GeV\), \(-1\)]\) \!\(\*SuperscriptBox[\(rad\), \(-1\)]\)]]", 
       Bottom], LabelStyle -> {FontSize -> 22}, 
     Method -> {FrameStyle -> Black, AxesStyle -> None, 
       TicksStyle -> Black}], Bottom], 
  PlotLabel -> 
   Style[Row[{"ALPs coupled to \[Gamma]. Primakov process. \
\!\(\*SubscriptBox[\(m\), \(a\)]\) = 1 GeV"}], 18, Black], 
  FrameTicks -> {{Automatic, Automatic}, {TicksPlotx, None}}]
$\endgroup$
4
  • 1
    $\begingroup$ For the best consistent performance, I never export but always use EDIT-> COPY_AS->BITMAP from the menu and paste into another app for saving/conversion. Most MS OFFICE apps and even MS PAINT work very well. $\endgroup$
    – OpticsMan
    May 31, 2023 at 21:40
  • $\begingroup$ @OpticsMan : in the current case, I cannot copy the whole object, since it is splitter onto the plot itself, the plot range and map. $\endgroup$ Jun 1, 2023 at 7:38
  • 1
    $\begingroup$ Not sure that I understand your comment. You can select either the 1) plot itself or 2) plot and the Barlegend together. To select #2, on Windows at least) to the right of the plot left-click-hold and drag to select. $\endgroup$
    – OpticsMan
    Jun 1, 2023 at 14:14
  • $\begingroup$ @OpticsMan : good point, thanks! I will check. $\endgroup$ Jun 1, 2023 at 19:33

0

Your Answer

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

Browse other questions tagged or ask your own question.