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

后端 未结 3 1278
刺人心
刺人心 2021-01-31 11:25

What is the simplest way to create a row/column/grid of plots, with the whole grid having a single FrameLabel?

I need something similar to this:

p := Lis         


        
相关标签:
3条回答
  • 2021-01-31 12:02

    You already know how to handle multiple horizontal labels through ListPlot. You can get single labels by using Panel. For example...

    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

    You can optionally include labels on Top and Right edges too.

    0 讨论(0)
  • 2021-01-31 12:16

    You can use LevelScheme to achieve what you want. Here's an example:

    << "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 offers you tremendous flexibility in the arrangement of your plot.

    • Instead of naming giving the plot common labels, you can move the definition inside the FigurePanel[] and control the labels for each one individually.
    • You can set inter-plot spacings both in the X and Y directions and also change the sizes of each panel, for e.g., the left one can take up 2/3 of the space and the next two just 1/6 of the space each.
    • You can set individual plot ranges, change the frame tick labels for each, control which side of the panel (top/bottom/l/r) the labels should be marked, change panel numberings, etc.

    The only drawback is that you might have to wrestle with it in some cases, but in general, I've found it a pleasure to use.

    EDIT

    Here's one similar to your example:

    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

    EDIT 2

    To answer Mr. Wizard's comment, here's a blank template for a 2x3 grid

    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

    And here's one with extended panels

    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

    0 讨论(0)
  • 2021-01-31 12:19

    Here is one option I just put together. Its advantage is that it is simple.

    I like the look of yoda's LevelScheme plots better, assuming those can be done for a grid as well.

    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

    0 讨论(0)
提交回复
热议问题