问题
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?
回答1:
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"}]
}]
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.
回答2:
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}
]
来源:https://stackoverflow.com/questions/5008267/vertical-alignment-of-plots-in-mathematica-via-graphicscolumn