如何使用LevelScheme在Mathematica中创建子图? [英] How do I create subplots in Mathematica using LevelScheme?

查看:158
本文介绍了如何使用LevelScheme在Mathematica中创建子图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下面在MATLAB中生成的任意图形为例.基本思想是,我有一个等高线图,我想在右侧的子图中显示从中选择的切片. mma中是否有等效的子图?

Consider the following arbitrary figure generated in MATLAB as an example. The basic idea is that I have a contour plot and I want to showcase selected slices from it in subplots on the right. Is there an equivalent of subplot in mma?

我现在要解决的问题是,仅将等高线图与切片和箭头以及两个切片图分开,然后将它们放在乳胶中.但是,我希望能够在mma中做到这一点.我该怎么做呢?

The work around that I have right now is to have just the contour plot with the slices and the arrows and the two slice-plots separately and then put them together in latex. However, I'd like to be able to do this within mma. How do I go about doing this?

我的想法是生成一个具有完全垂直和等高线的等高线图.半高宽比,两个垂直半高的图半水平宽高比,然后使用GraphicsGrid使其对齐.但是,这仍然使我可以将这些图作为列表,而不是合成图.这是唯一的方法,还是有更好,更优雅的方法呢?

An idea that I had is to generate a the contour plot with a full vertical & half horizontal aspect ratio, the two plots with half vertical & half horizontal aspect ratio, and then use GraphicsGrid to align them up. But this still gave me the plots as a list, not a composite figure. Is this the only way or is there a nicer, more elegant way of doing it?

推荐答案

我知道Multipanel > LevelScheme 可能可以让您做您想要的事情-但我对此没有太多经验,并且文档中的示例相当稀疏. 我已经将示例之一粘贴到了这样的示例中答案,所以在那里看看,看看你的想法!

I know that Multipanel in LevelScheme can probably let you do what you want - but I don't have much experience with it and the examples in the docs are fairly sparse. I've already pasted one of the examples into this SO answer, so have a look there and see what you think!

这是我尝试的GraphicsGrid. Multipanel允许您执行但GraphicsGrid不能执行的操作 是为了让您使用不同的列/行大小. 这意味着我很难以编程的方式绘制箭头,而不得不使用绘图工具"面板(:D)手工绘制箭头.

Here's my attempt with GraphicsGrid. The thing that Multipanel lets you do but GraphicsGrid doesn't is to let you use varying Column/Row sizes. This means that I struggled to get the arrows drawn in programmatically, and resorted to hand drawing them using the "Drawing Tools" panel ( :D )

With[{yslice1 = .5, yslice2 = -.8},
 GraphicsGrid[
  {{DensityPlot[Sin[15 x y], {x, -1, 1}, {y, -1, 1}, 
     ColorFunction -> "PlumColors", AspectRatio -> 2,
     Epilog -> {Dashed, White, Line[{{-1, yslice1}, {1, yslice1}}], 
       Line[{{-1, yslice2}, {1, yslice2}}]}],
    Plot[Sin[15 x yslice1], {x, -1, 1}, Axes -> False, Frame -> True]},
   {SpanFromAbove,
    Plot[Sin[15 x yslice2], {x, -1, 1}, Axes -> False, 
     Frame -> True]}},
  Spacings -> {Scaled[0.2], Scaled[0.0]}]]

这与使用LevelScheme的情况相同,请注意框架对齐. 应该可以添加箭头-因为LevelScheme有很多新的箭头指令-但我将其留为作业问题!

Here's the same thing using LevelScheme, note that the frames line up. It should be possible to add arrows - since LevelScheme has lots of new arrow directives - but I'll leave that as a homework problem!

<< "LevelScheme`"
{yslice1 = .5, yslice2 = -.8};
Figure[{
  SetOptions[Multipanel, 
   ShowTickLabels -> {True, False, False, True}, Background -> Wheat,
   PanelLetterFontSize -> 10, Margin -> {{40, 40}, {40, 0}}],
  Multipanel[{{0, 1}, {0, 1}}, {2, 2},
   XPlotRanges -> {-1, 1}, YPlotRanges -> {-1, 1},
   XFrameLabels -> textit["x"], YFrameLabels -> textit["y"],
   TickFontSize -> 10, XFrameTicks -> LinTicks[-1, 1, .5, 4], 
   YFrameTicks -> LinTicks[-1, 1, .5, 4],
   BufferL -> 1.5, BufferB -> 3, Order -> Vertical,
   XPanelSizes -> {1, 1}, XGapSizes -> 0.25, YGapSizes -> 0.2],
  FigurePanel[{1, 2}], 
  RawGraphics[
   Plot[Sin[15 x yslice1], {x, -1, 1}, Axes -> False, Frame -> True]],
  FigurePanel[{2, 2}], 
  RawGraphics[
   Plot[Sin[15 x yslice2], {x, -1, 1}, Axes -> False, Frame -> True]],
  FigurePanel[{2, 1}, PanelAdjustments -> {{0, 0}, {0, +1.2}}],
  RawGraphics[
   DensityPlot[Sin[15 x y], {x, -1, 1}, {y, -1, 1}, 
    ColorFunction -> "PlumColors", AspectRatio -> 2],
   Graphics[{Dashed, Thick, White, 
     Line[{{-1, yslice1}, {1, yslice1}}], 
     Line[{{-1, yslice2}, {1, yslice2}}]}]]},
 PlotRange -> {{0, 1}, {0, 1}}, ImageSize -> 2*72*{5, 3}
 ]

这篇关于如何使用LevelScheme在Mathematica中创建子图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆