Recipes/StackedPlots

This is probably more complicated than it needs to be. However, it's definitely very linearly written!

(doPlot is unnecessary; however, it makes for added readability.) Note that the ClusterFilePlots recipe is much simpler, although all of its plots are standalone.

import yt.lagos as lagos
from yt import ytcfg
ytcfg.set("raven","backend","MPL")
import yt.raven as raven
import sys

cls = []
a=[5, 10, 15, 20, 25, 30, 43]
a.reverse()
for i in a:
    print i
    cl = lagos.AnalyzeClusterOutput("ClusterFiles/DataDump%04i_AnalyzeCluster" % (i))
    cl += lagos.AnalyzeClusterOutput("ClusterFiles/DataDump%04i_AnalyzeCluster.Species" % (i))
    cls.append(cl)

import matplotlib.figure
from matplotlib.backends.backend_agg import FigureCanvasAgg

def doPlot(plot, cls, x, y):
    for cl in cls:
        plot(cl[x],cl[y], lw=2.5)

fig = matplotlib.figure.Figure(figsize=(12,8))
fig.subplots_adjust(hspace=0,wspace=0, bottom=0.05, top=0.95)
canvas = FigureCanvasAgg(fig) 

ax=fig.add_subplot(2,1,1)
doPlot(ax.semilogx,cls,"RAU","Mach")
ax.set_ylabel("Radial Mach Number", fontsize=16)
ax.set_xlim(1e-3, 1e5)
ax.set_ylim(0.0, 2.0)
ax.set_xticklabels(())
ax.axesFrame.set_linewidth(2.5)

ax=fig.add_subplot(2,1,2)
doPlot(ax.semilogx,cls,"RAU","TurbMach")
ax.set_xlabel("R (AU)", fontsize=16)
ax.set_ylabel("Turbulent Mach Number", fontsize=16)
ax.set_xlim(1e-3, 1e5)
ax.set_ylim(0.0, 2.0)
ax.axesFrame.set_linewidth(2.5)

fig.savefig("my_stacked_plot.png")