2
$\begingroup$

I have:

Legended[
Show[ Plot[1/(2 Pi x^2), {x, 0.26, 1}, 
PlotStyle -> {RGBColor[0.368417, 0.506779, 0.709798], Thick}, 
PlotRange -> {{0.26, 1}, {0, 3}}, 
BaseStyle -> {FontFamily -> "Latin Modern Math"}], 
Plot[1 - x, {x, 0.26, 1}, 
PlotStyle -> {RGBColor[1, 0.75, 0], Thick}, 
PlotRange -> {{0.26, 1}, {0, 3}}, 
BaseStyle -> {FontFamily -> "Latin Modern Math"}], 
LabelStyle -> {18, GrayLevel[0]}, 
AxesOrigin -> {0.26, 0}], {Placed[
Style[HoldForm[Subscript[p, 6]], FontSize -> 20, 
FontFamily -> "Latin Modern Roman 10"], {{1, 0.12}}], 
Placed[Style[HoldForm[Subscript[\[Mu], 2]], FontSize -> 20, 
FontFamily -> "Latin Modern Roman 10"], {{0.11, 1.02}}]}]

which gives:

enter image description here

It's clear that the font of $p_6$ is not roman. Why doesn't Style work properly with Legended and how can I fix it?

EDIT

$p_6$ and $\mu_2$ are my axes labels, but in my real case using AxesLabel results in a bad position of the labels, for example:

enter image description here

So, this was the reason that I used Legended; however, I don't know why assigning a special font to the labels doesn't work anymore.

$\endgroup$
1
  • $\begingroup$ Add FontSlant -> Italic to see if it makes a difference ? Another option would be to install and use MaTeX. Visit homepage set up by the author. $\endgroup$
    – Syed
    Mar 5, 2023 at 2:18

2 Answers 2

1
$\begingroup$
  • Method-1 Add some blank " " before the axes labels.
Show[Plot[1/(2 Pi x^2), {x, 0.26, 1}, 
  PlotStyle -> {RGBColor[0.368417, 0.506779, 0.709798], Thick}, 
  PlotRange -> {{0.26, 1}, {0, 3}}, 
  BaseStyle -> {FontFamily -> "Latin Modern Math"}], 
 Plot[1 - x, {x, 0.26, 1}, PlotStyle -> {RGBColor[1, 0.75, 0], Thick},
   PlotRange -> {{0.26, 1}, {0, 3}}, 
  BaseStyle -> {FontFamily -> "Latin Modern Math"}], 
 LabelStyle -> {18, GrayLevel[0]}, AxesOrigin -> {0.26, 0}, 
 AxesLabel -> {" " Style[  HoldForm[Subscript[p, 6]], FontSize -> 20, 
     FontFamily -> "Latin Modern Roman 10"], 
   Style[HoldForm[Subscript[μ, 2]], FontSize -> 20, 
    FontFamily -> "Latin Modern Roman 10"]}]

enter image description here

  • Method-2

Maybe add PlotRangePadding -> {{0, .08}, {0, .01}} and some arrows to make the axes label away from the axes.

Show[Plot[1/(2 Pi x^2), {x, 0.26, 1}, 
  PlotStyle -> {RGBColor[0.368417, 0.506779, 0.709798], Thick}, 
  PlotRange -> {{0.26, 1}, {0, 3}}, 
  BaseStyle -> {FontFamily -> "Latin Modern Math"}], 
 Plot[1 - x, {x, 0.26, 1}, PlotStyle -> {RGBColor[1, 0.75, 0], Thick},
   PlotRange -> {{0.26, 1}, {0, 3}}, 
  BaseStyle -> {FontFamily -> "Latin Modern Math"}], 
 LabelStyle -> {18, GrayLevel[0]}, AxesOrigin -> {0.26, 0}, 
 AxesLabel -> {Style[HoldForm[Subscript[p, 6]], FontSize -> 20, 
    FontFamily -> "Latin Modern Roman 10"], 
   Style[HoldForm[Subscript[μ, 2]], FontSize -> 20, 
    FontFamily -> "Latin Modern Roman 10"]}, 
 FormatType -> TraditionalForm, 
 PlotRangePadding -> {{0, .08}, {0, .01}}, 
 AxesStyle -> Arrowheads[{{.04}}]]

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ @Rose PlotRangePadding -> {{0, .08}, {0, .01}} work. $\endgroup$
    – cvgmt
    Mar 5, 2023 at 11:50
0
$\begingroup$
Clear["Global`*"]

The legend would be specified as

Legended[
 Show[
  Plot[1/(2 Pi x^2), {x, 0.26, 1},
   PlotStyle -> {RGBColor[0.368417, 0.506779, 0.709798], Thick}, 
   PlotRange -> {{0.26, 1}, {0, 3}},
   BaseStyle -> {FontFamily -> "Latin Modern Math"}],
  Plot[1 - x, {x, 0.26, 1},
   PlotStyle -> {RGBColor[1, 0.75, 0], Thick},
   PlotRange -> {{0.26, 1}, {0, 3}},
   BaseStyle -> {FontFamily -> "Latin Modern Math"}],
  LabelStyle -> {18, GrayLevel[0]},
  AxesOrigin -> {0.26, 0}],
 Placed[
  LineLegend[
   {Directive[RGBColor[0.368417, 0.506779, 0.709798], Thick],
    Directive[RGBColor[1, 0.75, 0], Thick]},
   {Style[HoldForm[Subscript[p, 6]],
     FontSize -> 20,
     FontFamily -> "Latin Modern Roman 10"],
    Style[HoldForm[Subscript[μ, 2]],
     FontSize -> 20,
     FontFamily -> "Latin Modern Roman 10"]}], {0.6, 0.5}]]

enter image description here

However this can be simplified to

Plot[{1/(2 Pi x^2), 1 - x}, {x, 0.26, 1},
 PlotStyle -> Thick,
 PlotRange -> {{0.26, 1}, {0, 3}},
 PlotRangePadding -> Scaled[.03],
 BaseStyle -> {FontFamily -> "Latin Modern Math"},
 LabelStyle -> {18, GrayLevel[0]},
 AxesOrigin -> {0.26, 0},
 AxesLabel -> {x, None},
 PlotLegends ->
  Placed[{Style[HoldForm[Subscript[p, 6]],
     20, "Latin Modern Roman 10"],
    Style[HoldForm[Subscript[μ, 2]],
     20, "Latin Modern Roman 10"]},
   {0.6, 0.5}]]

enter image description here

$\endgroup$
0

Your Answer

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