(*------------------------------------------------...
创建于:2025年5月21日
使用 O4 Mini High 回答 Chat01
创建于:2025年5月21日
使用 O4 Mini High 回答 Chat01
(------------------------------------------------)(一、参数与函数)
ClearAll["Global`"];
M = 1; (质量参数)
L = 4; (角动量)
gs = {0, 0.5, 0.7}; (不同磁荷 g)
cols = {Blue, Orange, Green}; (每条曲线的颜色)
f[r_, g_] := 1 - (2 M r^2)/(r^2 + g^2)^(3/2);
Veff[r_, L_, g_] := f[r, g] (1 + L^2/r^2);
legend =
LineLegend[cols, Thread["g = " <> ToString /@ gs],
LegendMarkers -> "Line", LabelStyle -> 12];
(------------------------------------------------)
(二、极值计算:FindMaximum 找局部峰值)
extrema =
Table[Module[{res =
FindMaximum[{Veff[r, L, g], r > 0}, {r, 3}]}, {g, res[[2, 1, 2]],
res[[1]]} ({g,r_max,V_max})], {g, gs}];
(表格形式展示结果)
extremaTable =
Grid[Prepend[extrema, Style[{"g", "r_max", "V_max"}, Bold]],
Frame -> All, Alignment -> Center, ItemSize -> {{3, 5, 5}}];
(------------------------------------------------)
(三、绘图函数(全局/局部共用))
makePlot[{ymin_, ymax_}] :=
Plot[Evaluate@Table[Veff[r, L, g], {g, gs}], {r, 1, 10},
PlotRange -> {All, {ymin, ymax}}, PlotStyle -> cols,
Epilog ->
MapThread[{#1, PointSize[0.015],
Point[{#2[[2]], #2[[3]]}]} &, {cols, extrema}],
PlotLegends ->
Placed[LineLegend[cols, {"g = 0", "g = 0.5", "g = 0.7"},
LabelStyle -> 12], Scaled[{0.80, 0.20}] (右下角,绝对看得见)],
AxesLabel -> {Style["r", Italic, 12],
Style[Subscript[V, eff][r], Italic, 12]}, ImageSize -> 500,
ImagePadding -> 25, PlotTheme -> "Scientific"];
globalPlot = makePlot[{-17, 1.1}]; (全范围)
localPlot = makePlot[{0.8, 1.1}]; (局部放大)
(------------------------------------------------*)
(四、一次性输出:全局图、局部图、极值表)
Column[{globalPlot, localPlot, extremaTable}, Spacings -> 2,
Alignment -> Center]
the output of this MMA code has no axes tag, which is awful.
You’re right—PlotTheme→"Scientific"
in recent versions of Mathematica will, by default, replace the usual axes with a framed box, and since you only supplied AxesLabel
the labels never actually get drawn. You have two simple fixes:
Bring back the classic axes and use your AxesLabel
Just override the theme’s framing by forcing
mathematicaAxes → True, Frame → False
so that your existing AxesLabel
appears. For example:
mathematicamakePlot[{ymin_, ymax_}] := Plot[ Evaluate@Table[Veff[r, L, g], {g, gs}], {r, 1, 10}, PlotRange → {All, {ymin, ymax}}, PlotStyle → cols, Epilog → MapThread[ {#1, PointSize[0.015], Point[{#2[[2]], #2[[3]]}]} &, {cols, extrema}], PlotLegends → Placed[ LineLegend[cols, {"g = 0", "g = 0.5", "g = 0.7"}, LabelStyle → 12], Scaled[{0.80, 0.20}] ], Axes → True, (* ← force axes back *) Frame → False, (* ← turn off the theme’s frame *) AxesLabel → { Style["r", Italic, 12], Style[Subscript[V, eff][r], Italic, 12] }, AxesStyle → Thick, ImageSize → 500, ImagePadding → 25, PlotTheme → "Scientific" ];
Stick with the framed style but switch to FrameLabel
If you actually like the “Scientific” boxed look, then leave Frame→True
(the theme default) and replace your AxesLabel
with FrameLabel
:
mathematicamakePlot[{ymin_, ymax_}] := Plot[ Evaluate@Table[Veff[r, L, g], {g, gs}], {r, 1, 10}, PlotRange → {All, {ymin, ymax}}, PlotStyle → cols, Epilog → MapThread[ {#1, PointSize[0.015], Point[{#2[[2]], #2[[3]]}]} &, {cols, extrema}], PlotLegends → Placed[ LineLegend[cols, {"g = 0", "g = 0.5", "g = 0.7"}, LabelStyle → 12], Scaled[{0.80, 0.20}] ], Frame → True, (* ← keep the box *) Axes → False, (* ← no classic axes *) FrameLabel → { Style["r", Italic, 12], Style[Subscript[V, eff][r], Italic, 12] }, FrameStyle → Thick, ImageSize → 500, ImagePadding → 25, PlotTheme → "Scientific" ];
Either approach will give you visible, styled axis labels (“标签”) again.