Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] Fix rendering of plots in some examples where titles or images are cut off #3753

Merged
merged 12 commits into from
Jul 14, 2023
2 changes: 1 addition & 1 deletion doc/changes/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Fixes

- Relax the :func:`~nilearn.interfaces.fmriprep.load_confounds` confounds selection on `cosine` as not all confound files contained the variables (:gh:`3816` by `Hao-Ting Wang`_).


Enhancements
------------

Expand All @@ -42,3 +41,4 @@ Changes
- :bdg-danger:`Deprecation` Empty region signals resulting from applying `mask_img` in :class:`~maskers.NiftiLabelsMasker` will no longer be kept in release 0.15. Meanwhile, use `keep_masked_labels` parameter when initializing the :class:`~maskers.NiftiLabelsMasker` object to enable/disable this behavior. (:gh:`3722` by `Mohammad Torabi`_).
- :bdg-danger:`Deprecation` Empty region signals resulting from applying `mask_img` in :class:`~maskers.NiftiMapsMasker` will no longer be kept in release 0.15. Meanwhile, use `keep_masked_maps` parameter when initializing the :class:`~maskers.NiftiMapsMasker` object to enable/disable this behavior. (:gh:`3732` by `Mohammad Torabi`_).
- Removed mention of license in "header" (:gh:`3838` by `Czarina Sy`_).
- Configure plots in example gallery for better rendering (:gh:`3753` by `Yasmin Mzayek`_)
4 changes: 2 additions & 2 deletions examples/01_plotting/plot_demo_glass_brain_extensive.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@

display = plot_glass_brain(None, display_mode="lr")
display.add_contours(stat_img, levels=[3.0], colors="r")
display.title('"stat_img" on glass brain only "l" "r" hemispheres')
display.title('"stat_img" on glass brain only\n"l" "r" hemispheres')


##############################################################################
# Filled contours in both hemispheric plotting, by adding ``filled=True``.

display = plot_glass_brain(None, display_mode="lr")
display.add_contours(stat_img, filled=True, levels=[3.0], colors="r")
display.title('Filled contours on glass brain only "l" "r" hemispheres')
display.title('Filled contours on glass brain only\n"l" "r" hemispheres')


##############################################################################
Expand Down
7 changes: 5 additions & 2 deletions examples/01_plotting/plot_demo_more_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@
# :class:`~nilearn.plotting.displays.YSlicer` object.
# ``cut_coords`` is provided as an integer (1), and the coordinates are,
# again, selected automatically.
import matplotlib.pyplot as plt

plotting.plot_stat_map(stat_img, display_mode='y', cut_coords=1,
title="display_mode='y', cut_coords=1")
title="display_mode='y', cut_coords=1",
figure=plt.figure(figsize=(5, 4)))

###############################################################################
# Visualizing without a colorbar on the right side
Expand All @@ -127,7 +129,8 @@

plotting.plot_stat_map(stat_img, display_mode='z',
cut_coords=1, colorbar=False,
title="display_mode='z', cut_coords=1, colorbar=False")
title="display_mode='z', cut_coords=1,\ncolorbar=False",
figure=plt.figure(figsize=(5, 7)))

###############################################################################
# Visualize in - two views 'sagittal' and 'axial' with given coordinates
Expand Down
2 changes: 1 addition & 1 deletion examples/01_plotting/plot_haxby_masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
p_v = Rectangle((0, 0), 1, 1, fc="red")
p_h = Rectangle((0, 0), 1, 1, fc="blue")
p_f = Rectangle((0, 0), 1, 1, fc="limegreen")
plt.legend([p_v, p_h, p_f], ["vt", "house", "face"])
plt.legend([p_v, p_h, p_f], ["vt", "house", "face"], loc="lower right")

show()

Expand Down
5 changes: 3 additions & 2 deletions examples/02_decoding/plot_haxby_different_estimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
# Then we make a rudimentary diagram
import matplotlib.pyplot as plt

plt.figure(figsize=(6, 6))
plt.figure(figsize=(8, 6))

all_categories = np.sort(np.hstack([categories, "AVERAGE"]))
tick_position = np.arange(len(all_categories))
Expand All @@ -141,7 +141,7 @@
plt.xlabel("Classification accuracy (AUC score)")
plt.ylabel("Visual stimuli category")
plt.xlim(xmin=0.5)
plt.legend(loc="lower left", ncol=1)
plt.legend(ncol=1, bbox_to_anchor=(1.3, 0.2))
plt.title(
"Category-specific classification accuracy for different classifiers"
)
Expand Down Expand Up @@ -198,6 +198,7 @@
cut_coords=[-15],
threshold=threshold,
title=f"{classifier_name.replace('_', ' ')}: face vs house",
figure=plt.figure(figsize=(3, 4)),
)

show()
Expand Down
2 changes: 1 addition & 1 deletion examples/02_decoding/plot_oasis_vbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
title = (
"Negative $\\log_{10}$ p-values" "\n(Non-parametric + max-type correction)"
)
display.title(title, y=1.2)
display.title(title)

n_detections = (get_data(signed_neg_log_pvals_unmasked) > threshold).sum()
print(f"\n{int(n_detections)} detections")
Expand Down
2 changes: 1 addition & 1 deletion examples/02_decoding/plot_simulated_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def plot_slices(data, title=None):
hspace=0.05, wspace=0.05, left=0.03, right=0.97, top=0.9
)
if title is not None:
plt.suptitle(title, y=0.95)
plt.suptitle(title)


###############################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
display_mode="z",
plot_abs=False,
title="group left-right button press (unc p<0.001)",
figure=plt.figure(figsize=(5, 5)),
)
plotting.show()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
for image, strategy in zip(images, ["percentile", "image intensity"]):
title = (
f"ROIs using {strategy} thresholding. "
"\n Each ROI in same color is an extracted region"
"Each ROI in same color is an extracted region"
)
plotting.plot_prob_atlas(
image,
Expand Down
1 change: 1 addition & 0 deletions examples/07_advanced/plot_bids_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,6 @@
title="Group language network (unc p<0.001)",
plot_abs=False,
display_mode="x",
figure=plt.figure(figsize=(5, 4)),
)
plotting.show()
4 changes: 2 additions & 2 deletions examples/07_advanced/plot_haxby_mass_univariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
f"\n{n_detections} detections"
)

display.title(title, y=1.1)
display.title(title, size=10)

# Plot permutation p-values map
display = plot_stat_map(
Expand All @@ -197,7 +197,7 @@
f"\n{n_detections} detections"
)

display.title(title, y=1.1)
display.title(title, size=10)

show()

Expand Down
2 changes: 1 addition & 1 deletion examples/07_advanced/plot_localizer_simple_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@
f"\n{(~masked_pvals.mask).sum()} detections"
)

display.title(title, y=1.1, alpha=0.8)
display.title(title, y=1, alpha=0.8)

show()