关于Wolfram Mathematica:如何使用一对FrameLabels绘制网格图?

How to make a grid of plots with a single pair of FrameLabels?

在整个网格只有一个FrameLabel的情况下,创建图的行/列/网格的最简单方法是什么?

我需要类似以下内容:

1
2
3
4
5
p := ListPlot[RandomInteger[10, 5], Joined -> True, Axes -> False,
  Frame -> True, PlotRange -> {0, 11},
  FrameLabel -> {"horizontal", None}, AspectRatio -> 1]

GraphicsRow[{Show[p, FrameLabel -> {"horizontal","vertical"}], p, p}]

对于行格式,它可以具有一个或多个水平标签,但只能有一个垂直标签。

要考虑的问题:

  • 垂直比例尺必须与所有plot相匹配,并且不得因以下原因而破坏:标签太长或自动PlotRangePadding
  • 需要良好地(且具有调整大小的公差!)控制图间间距(毕竟,这是删除冗余标签的动机之一)
  • 安排的总体空间效率。最大内容,最小(不必要)空格。

编辑

我正在尝试能够可靠地创建可打印的图形,这涉及很多调整大小。 (因为导出的PDF通常与我在笔记本中看到的比例不一样,并且必须具有可读但不大的字体)。


您可以使用LevelScheme实现所需的功能。这是一个示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<<"LevelScheme`"
Figure[{
  Multipanel[{{0, 1}, {0, 1}}, {1, 3},
   XFrameLabels -> textit["x"], BufferB -> 3,
   YFrameLabels -> textit["Sinc(x)"], BufferL -> 3,
   TickFontSize -> 9,
   XGapSizes -> {0.1, 0.1},
   PanelLetterCorner -> {1, 1}
   ],
  FigurePanel[{1, 1}, PlotRange -> {{-1.6, -0.6}, {-0.5, 1}}],
  RawGraphics[Plot[Sinc[20 x], {x, -1.6, -0.6}]],

  FigurePanel[{1, 2}, PlotRange -> {{-0.5, 0.5}, {-0.5, 1}}],
  RawGraphics[Plot[Sinc[20 x], {x, -0.5, 0.5}]],

  FigurePanel[{1, 3}, PlotRange -> {{0.6, 1.6}, {-0.5, 1}}],
  RawGraphics[Plot[Sinc[20 x], {x, 0.6, 1.6}]]
  },
 PlotRange -> {{-0.1, 1.02}, {-0.12, 1.095}}]

enter image description here

LevelScheme为您提供情节安排的极大灵活性。

  • 您可以将定义移至FigurePanel[]内并分别控制每个标签,而不必为绘图指定通用标签。
  • 您可以在X和Y方向上都设置图间距,也可以更改每个面板的大小,例如,左边的面板可以占据2/3的空间,接下来的两个面板可以仅占空间的1/6。 。
  • 您可以设置单独的绘图范围,更改每个框的刻度线标签,控制应在面板的哪一侧(顶部/底部/ l / r)进行标记,更改面板编号等。

唯一的缺点是,在某些情况下您可能需要花点功夫,但总的来说,我发现使用它很有趣。

编辑

以下是与您的示例类似的内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Figure[{
  Multipanel[{{0, 1}, {0, 1}}, {1, 3},
   YFrameLabels -> textit["Vertical"], BufferL -> 3,
   TickFontSize -> 9,
   XGapSizes -> {0.1, 0.1},
   PanelLetterCorner -> {1, 1}
   ],
  FigurePanel[{1, 1}, PlotRange -> {{1, 10}, {0, 10}}],
  RawGraphics[ListLinePlot[RandomInteger[10, 10]]],

  FigurePanel[{1, 2}, PlotRange -> {{1, 10}, {0, 10}},
   LabB -> textit["Horizontal"], BufferB -> 3],
  RawGraphics[ListLinePlot[RandomInteger[10, 10]]],

  FigurePanel[{1, 3}, PlotRange -> {{1, 10}, {0, 10}}],
  RawGraphics[ListLinePlot[RandomInteger[10, 10]]]
  },
 PlotRange -> {{-0.1, 1.02}, {-0.2, 1.095}}]

enter image description here

编辑2

要回答向导先生的评论,这是2x3网格的空白模板

1
2
3
4
5
6
7
8
9
10
11
12
Figure[{Multipanel[{{0, 1}, {0, 1}}, {2, 3},
   XFrameTicks -> None,
   YFrameTicks -> None,
   XGapSizes -> {0.1, 0.1},
   YGapSizes -> {0.1}],
  FigurePanel[{1, 1}],
  FigurePanel[{1, 2}],
  FigurePanel[{1, 3}],
  FigurePanel[{2, 1}],
  FigurePanel[{2, 2}],
  FigurePanel[{2, 3}]
  }, PlotRange -> {{-0.01, 1.01}, {-0.01, 1.01}}]

enter image description here

这是带有扩展面板的那个

1
2
3
4
5
6
7
8
9
10
Figure[{Multipanel[{{0, 1}, {0, 1}}, {2, 3},
   XFrameTicks -> None,
   YFrameTicks -> None,
   XGapSizes -> {0.1, 0.1},
   YGapSizes -> {0.1}],
  FigurePanel[{1, 1}, PanelAdjustments -> {{0, 0}, {1.1, 0}}],
  FigurePanel[{1, 2}],
  FigurePanel[{1, 3}],
  FigurePanel[{2, 2}, PanelAdjustments -> {{0, 1.1}, {0, 0}}]
  }, PlotRange -> {{-0.01, 1.01}, {-0.01, 1.01}}]

enter image description here


您已经知道如何通过ListPlot处理多个水平标签。
您可以使用Panel获得单个标签。例如...

1
2
3
4
5
p := ListPlot[RandomInteger[10, 5], Joined -> True, Axes -> False,
Frame -> True, PlotRange -> {0, 11}, AspectRatio -> 1]

Panel[GraphicsRow[{p, p, p}], {"horizontal",Rotate["vertical", Pi/2]},
      {Bottom, Left}, Background -> White]

triptych

您也可以选择在TopRight边缘上包括标签。


这是我刚刚提出的一种选择。它的优点是它很简单。

我更喜欢yoda的LevelScheme图的外观,假设这些也可以在网格上完成。

1
2
3
4
5
6
7
p := ListPlot[RandomInteger[10, 5], Joined -> True, Axes -> False,
  Frame -> True, PlotRange -> {0, 11}, AspectRatio -> 1]

gg = GraphicsGrid[{{p, p, p}, {p, p, p}, Graphics /@ Text /@ {"Left","Center","Right"}},
       Spacings -> 5, ItemAspectRatio -> {{1, 1, 0.15}}];

Labeled[gg, Rotate["vertical", Pi/2], Left]

enter image description here