通过 GraphicsColumn 在 mathematica 中垂直对齐绘图

发布于 2024-10-17 13:13:01 字数 286 浏览 3 评论 0原文

我在 Mathematica 中使用 GraphicsColumn() 将多个 DateList 绘图合并到一列中时遇到了一个恼人的问题。我需要它们正确对齐,因为它们显示同一时期的不同时间序列,但事实证明,每个图的框架大小会根据 Y 轴标签的长度自动调整大小。因此,将带有 5 位数标签的绘图和带有 2 位数标签的绘图结合起来将完全危害垂直对齐。我尝试了几种调整(例如通过 ImageSize 设置宽度或最大宽度),不幸的是它们似乎都适用于整个图形的大小,而不是实际的框架。我似乎没有找到一种方法来控制框架本身的大小。有什么想法吗?

I have an annoying problem using GraphicsColumn() in Mathematica to combine several DateList plots in a single column. I need them to be correctly aligned as they display different timeseries for the same period, but as it turns out the size of the frame of each plot gets automatically resized depending on the length of the Y-axis labels. So combining a plot with 5-figure labels and one with 2-figure labels will totally jeopardise the vertical alignment. I tried several tweaks (e.g. setting width or max width via ImageSize), unfortunately they all seem to apply to the size of the graphic as a whole, not the actual frame. I don't seem to find a way to control the size of the frame itself. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

少女情怀诗 2024-10-24 13:13:01

我怀疑您想设置 ImagePadding 选项:


GraphicsColumn[{
  Plot[Sin[x], {x, 0, 2 Pi}, ImagePadding -> 20, AxesLabel -> {"x", "very very loooooooong"}],
Plot[Sin[x], {x, 0, 2 Pi}, ImagePadding -> 20, AxesLabel -> {"x", "shrt"}] }]

Mathematica graphics

我不确定您如何标记图表,但如果您将值设置得足够高以显示整个标签,则此方法应该有效。

I suspect you want to set the ImagePadding option:


GraphicsColumn[{
  Plot[Sin[x], {x, 0, 2 Pi}, ImagePadding -> 20, AxesLabel -> {"x", "very very loooooooong"}],
Plot[Sin[x], {x, 0, 2 Pi}, ImagePadding -> 20, AxesLabel -> {"x", "shrt"}] }]


Mathematica graphics

I am not sure how you are labeling the graph, but this method should work if you set the value high enough to show the whole label.

甜味超标? 2024-10-24 13:13:01

您可以尝试 LevelScheme 多面板命令。

这是他们的文档和 LevelSchemeExamples.nb 中给出的示例:

Figure[
 {ScaledLabel[{0.5, 1}, "Lissajous curves", FontSize -> 18, Offset -> {0, 1}],
  Multipanel[{{0, 1}, {0, 1}}, {2, 2},
   XPlotRanges -> {{-1.5, 1.5}, {-Pi/2, 8*Pi + Pi/2}},
   YPlotRanges -> {-1.5, 1.5},
   XFrameLabels -> {textit["x"], textit["t"]}, BufferB -> 2.5,
   YFrameLabels -> textit["y"], BufferL -> 3,
   TickFontSize -> 10,
   XFrameTicks -> {LinTicks[-2, 2, 1, 5], LinTicks[-Pi, 9*Pi, Pi, 4, 
      TickLabelFunction -> (Rationalize[#/Pi]*Pi &)]},
   YFrameTicks -> LinTicks[-2, 2, 1, 5],
   XPanelSizes -> {1, 2.5}, XGapSizes -> {0.1},
   YPanelSizes -> {1, 1}, YGapSizes -> {0.1},
   Background -> Wheat, PanelLetterBackground -> Wheat
   ],

  FigurePanel[{1, 1}],
  RawGraphics[ParametricPlot[{Cos[1*t], Cos[1*t - Pi/2]}, {t, 0, 2*Pi}]],

  FigurePanel[{1, 2}],
  RawGraphics[Plot[Cos[1*t], {t, 0, 8*Pi}], Dashing -> Automatic],
  RawGraphics[Plot[Cos[1*t - Pi/2], {t, 0, 8*Pi}]],

  FigurePanel[{2, 1}, PanelLetterBackground -> None],
  RawGraphics[ParametricPlot[{Cos[1*t], Cos[4*t - Pi/2]}, {t, 0, 2*Pi}]],

  FigurePanel[{2, 2}],
  RawGraphics[Plot[Cos[1*t], {t, 0, 8*Pi}], Dashing -> Automatic],
  RawGraphics[Plot[Cos[4*t - Pi/2], {t, 0, 8*Pi}]],
 },
 PlotRange -> {{-0.1, 1.1}, {-0.1, 1.1}}, 
 ImageSize -> 72*2*{3.6, 2.1}
]

Lissajous curve

You could try the the LevelScheme Multipanel command.

Here's the example given in their documentation and LevelSchemeExamples.nb:

Figure[
 {ScaledLabel[{0.5, 1}, "Lissajous curves", FontSize -> 18, Offset -> {0, 1}],
  Multipanel[{{0, 1}, {0, 1}}, {2, 2},
   XPlotRanges -> {{-1.5, 1.5}, {-Pi/2, 8*Pi + Pi/2}},
   YPlotRanges -> {-1.5, 1.5},
   XFrameLabels -> {textit["x"], textit["t"]}, BufferB -> 2.5,
   YFrameLabels -> textit["y"], BufferL -> 3,
   TickFontSize -> 10,
   XFrameTicks -> {LinTicks[-2, 2, 1, 5], LinTicks[-Pi, 9*Pi, Pi, 4, 
      TickLabelFunction -> (Rationalize[#/Pi]*Pi &)]},
   YFrameTicks -> LinTicks[-2, 2, 1, 5],
   XPanelSizes -> {1, 2.5}, XGapSizes -> {0.1},
   YPanelSizes -> {1, 1}, YGapSizes -> {0.1},
   Background -> Wheat, PanelLetterBackground -> Wheat
   ],

  FigurePanel[{1, 1}],
  RawGraphics[ParametricPlot[{Cos[1*t], Cos[1*t - Pi/2]}, {t, 0, 2*Pi}]],

  FigurePanel[{1, 2}],
  RawGraphics[Plot[Cos[1*t], {t, 0, 8*Pi}], Dashing -> Automatic],
  RawGraphics[Plot[Cos[1*t - Pi/2], {t, 0, 8*Pi}]],

  FigurePanel[{2, 1}, PanelLetterBackground -> None],
  RawGraphics[ParametricPlot[{Cos[1*t], Cos[4*t - Pi/2]}, {t, 0, 2*Pi}]],

  FigurePanel[{2, 2}],
  RawGraphics[Plot[Cos[1*t], {t, 0, 8*Pi}], Dashing -> Automatic],
  RawGraphics[Plot[Cos[4*t - Pi/2], {t, 0, 8*Pi}]],
 },
 PlotRange -> {{-0.1, 1.1}, {-0.1, 1.1}}, 
 ImageSize -> 72*2*{3.6, 2.1}
]

Lissajous curves

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文