I would like some advise about how to arrange matplotlib.figure.Figure objects
I make an object of type 'matplotlib.figure.Figure' using the following function ( https://nilearn.github.io/modules/generated/nilearn.plotting.plot_surf_roi.html ):
from nilearn import plotting
def plot_surf(surface_data, view, fig):
img = plotting.plot_surf_roi(surface_data['surf_mesh'],
roi_map=surface_data['comp_labels'],
hemi=hemi, view=view,
cmap='RdBu_r',
vmax=np.nanmax(surface_data['comp_labels']),
vmin=np.nanmin(surface_data['comp_labels']),
bg_map=surface_data['bg_maps'],
darkness=0.6,
bg_on_data=True,
title='',
figure = fig)
return img
I would like to make a few of these and arrange as subplots. This is my unsuccessful attempt so far:
fig = plt.figure()
fig, ax = plt.subplots()
plot_surf(surface_data, 'lateral', fig)
plot_surf(surface_data, 'medial', fig)
plt.show()
Any advice appreciated
Try to do this:
def plot_surf(surface_data, view, fig, axes):
img = plotting.plot_surf_roi(surface_data['surf_mesh'],
roi_map=surface_data['comp_labels'],
hemi=hemi, view=view,
cmap='RdBu_r',
vmax=np.nanmax(surface_data['comp_labels']),
vmin=np.nanmin(surface_data['comp_labels']),
bg_map=surface_data['bg_maps'],
darkness=0.6,
bg_on_data=True,
title='',
figure = fig,
axes=axes)
return img
fig, (ax1, ax2) = plt.subplots(2, subplot_kw={'projection': '3d'})
plot_surf(surface_data, 'lateral', fig, ax1)
plot_surf(surface_data, 'medial', fig, ax2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.