3
$\begingroup$

I'm using mathematica 12.3. The function I need to plot is of order $10^4$, and I want to display a multiplier "$\times 10^4$" besides the $y$-axix while keeping FrameLabels $x,y$.

With following code

Plot[x^2, {x, 0, 3}, 
     PlotTheme -> "Scientific", 
     FrameLabel -> {x, x^2}, 
     AxesLabel -> {, MaTeX@"\\times10^4"}]

I get

this

, where the AxesLabel doesn't show the multiplier.

If I remove PlotTheme,

Plot[x^2, {x, 0, 3}, 
     FrameLabel -> {x, x^2}, 
     AxesLabel -> {, MaTeX@"\\times10^4"}]

I get

enter image description here

, where the FrameLabel doesn't show anymore.

How shall I make it through, as simply as possible? Thanks.

$\endgroup$
0

5 Answers 5

3
$\begingroup$

Working around.

Plot[x^2, {x, 0, 3}, PlotTheme -> "Scientific", 
 FrameLabel -> {x, x^2}, 
 PlotLegends -> Placed[MaTeX@"\\times10^4", {Top, Left}]]

enter image description here

Plot[x^2, {x, 0, 3}, PlotTheme -> "Scientific", 
 FrameLabel -> {x, x^2}, 
 PlotLegends -> Placed[MaTeX@"\\times10^4", {0.1, 1}]]

enter image description here

$\endgroup$
2
$\begingroup$

maybe like this

Plot[x^2, {x, 0, 3}, PlotTheme -> "Scientific", 
 FrameLabel -> (MaTeX[#, FontSize -> 20] &) /@ {"x", 
    "x^2 \\ \\times 10^4"}]    

enter image description here

$\endgroup$
2
$\begingroup$
<< MaTeX`

Plot[x^2
 , {x, 0, 3}
 , PlotTheme -> "Scientific"
 , FrameLabel -> {
   MaTeX@"x", RowBox[
     {Spacer[90]
      , MaTeX@"x^2"
      , Spacer[70]
      , Rotate[
       MaTeX@"\\times10^4", -π/2]}] // DisplayForm
   }
 ]

enter image description here

$\endgroup$
2
$\begingroup$

You can use AxisObject; an experimental function in 13.1.

I have made most features Transparent so only the AxisLabel remains. Also had to ImagePadding above the to make space for the label.

Plot[
 x^2, {x, 0, 3}
 , PlotTheme -> "Scientific"
 , FrameLabel -> {x, x^2}
 , ImagePadding -> {{Automatic, Automatic}, {Automatic, 20}}
 , Prolog -> {
   AxisObject[{"Vertical", -0.05}
    , AxisStyle -> Transparent
    , TicksStyle -> Transparent
    , LabelStyle -> Opacity[1]
    , AxisLabel -> 
       Placed[TraditionalForm["\[Times]\[MediumSpace]\!\(\*SuperscriptBox[\(10\), \(4\)]\)"]
       , Above
       ]
    ]
   }]

Mathematica graphics

Hope this helps.

$\endgroup$
1
  • $\begingroup$ I'm using 12.3, so these codes don't seem to work in my PC, but thank you for the same. I'll try it after updating. $\endgroup$
    – Luessiaw
    Oct 23, 2022 at 16:25
1
$\begingroup$

Drawbacks of existing answers

@cvgmt's answer is helpful, but actually in my case, my $y$-axis label is very long, and Placed command doesn't show at desired postion.

For example, with a very long label and position {0.1,1}, I get

, where the $\times 10^4$ is placed above the whole graph. If I set the position to be {0.1,0.9}, I get something like

As it turns out, the position is now relative to Frame, not the whole Graph.

I don't know what causes it, and it's no use to replace Scaled by ImageScaled or just {0.1,0.9}.


My Improvement

I found [Overlay] to place one graph above another. And following codes

Overlay[{
    Plot[x^2, {x, 0, 3}, PlotTheme -> "Scientific", 
        ImagePadding -> {{Automatic, 20}, {Automatic, 20}}, 
        FrameLabel -> {x, MaTeX@"\\text{A Very Very Very Very Very Long Label}"}],

    Graphics[Inset[MaTeX@"\\times10^4", 
        ImageScaled@{0.18, 0.93}],
        ImageSize -> Small]
}]

will give

, which performs well.

ImagePadding is needed, otherwise $\times10^4$ will be cut off at the frame border.

$\endgroup$

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.