JustPaste.it

profiles = []
labels = []


ad=ds.all_data()
profiles.append(yt.create_profile(ad, ["number_density"],
fields=["H2_fraction"],accumulation=True))
labels.append("H2 fraction")
profiles.append(yt.create_profile(ad, ["number_density"],
fields=["El_fraction"],accumulation=True))
labels.append("El fraction")
plot = yt.ProfilePlot.from_profiles(profiles, labels=labels)

# Save the image.
plot.save()