我正在 Mathematica 中生成一个双面板图形。底部面板的 y 轴具有负值,这会导致该轴上使用 FrameLabel 生成的标签比顶部面板上具有正值的标签更向左对齐。我无法将面板连接到单个图,因为比例不同。 重现问题的一段代码:
pad = 80;
Export["C:\\Users\\user\\Desktop\\stackoverflow.png",
Column[
{
Show[
Plot[ Sin[x]^2, {x, 0, Pi},
FrameLabel -> {"", "y"},
BaseStyle -> {FontSize -> 16, FontWeight -> Bold,
FontFamily -> "Calibri"},
ImagePadding -> {{pad, pad/4}, {pad, pad/4}},
Frame -> {True, True, True, True}
]
, ImageSize -> 640]
,
Show[
Plot[ -Sin[x]^2/1000, {x, 0, Pi},
FrameLabel -> {"x", "y"},
BaseStyle -> {FontSize -> 16, FontWeight -> Bold,
FontFamily -> "Calibri"},
ImagePadding -> {{pad, pad/4}, {pad, pad/4}},
Frame -> {True, True, True, True}
]
, ImageSize -> 640]
}
]
]
此代码生成下图,其中您可以看到 y 标签在顶部和底部面板中的对齐方式不同。
如果有任何帮助,我将不胜感激 - 我必须尽快将数字(显然不是上面的数字...)提交给出版商,以便我的论文得以打印... 谢谢
最佳答案
我通过用 Inset 替换 FrameLabel 解决了这个问题:
Column[
{
Show[
Plot[ Sin[x]^2, {x, 0, Pi},
FrameLabel -> {"", ""},
Epilog -> {
Inset["y", ImageScaled[{0.01, 0.55}], {0, 0}, Automatic, {0, 1}]
},
BaseStyle -> {FontSize -> 16, FontWeight -> Bold,
FontFamily -> "Calibri"},
ImagePadding -> {{pad, pad/4}, {pad, pad/4}},
Frame -> {True, True, True, True},
PlotRangeClipping -> False
]
, ImageSize -> 640]
,
Show[
Plot[ -Sin[x]^2/1000, {x, 0, Pi},
FrameLabel -> {"x", ""},
PlotRangeClipping -> False,
Epilog -> {
Inset["y", ImageScaled[{0.01, 0.55}], {0, 0}, Automatic, {0, 1}]
},
BaseStyle -> {FontSize -> 16, FontWeight -> Bold,
FontFamily -> "Calibri"},
ImagePadding -> {{pad, pad/4}, {pad, pad/4}},
Frame -> {True, True, True, True}
]
, ImageSize -> 640]
}
]
产生以下结果:
我看到了发布的其他解决方案 - 谢谢你们,但我更喜欢我的解决方案,尽管它与 @Mr.Wizard 解决方案非常相似。很抱歉刚才发布了解决方案,但是当我找到它时,我无法发布,因为该网站要求我等待 8 小时才能回答我自己的问题。
关于wolfram-mathematica - 沃尔夫拉姆数学 : y-axis frame labels are not aligned,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9207569/