Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
yt-project
GitHub Repository: yt-project/yt
Path: blob/main/doc/source/cookbook/multiplot_export_to_mpl.py
928 views
1
import yt
2
3
ds = yt.load_sample("IsolatedGalaxy")
4
5
fields = [
6
("gas", "density"),
7
("gas", "velocity_x"),
8
("gas", "velocity_y"),
9
("gas", "velocity_magnitude"),
10
]
11
12
p = yt.SlicePlot(ds, "z", fields)
13
p.set_log(("gas", "velocity_x"), False)
14
p.set_log(("gas", "velocity_y"), False)
15
16
# this returns a matplotlib figure with an ImageGrid and the slices
17
# added to the grid of axes (in this case, 2x2)
18
fig = p.export_to_mpl_figure((2, 2))
19
20
fig.tight_layout()
21
22
fig.savefig("multiplot_export_to_mpl.png")
23
24