Skip to content

Commit

Permalink
[circle full] extend to plot_surf
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGensollen committed Jun 30, 2021
1 parent e4ffea5 commit eca1f35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nilearn/plotting/displays.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ def _get_cbar_ticks(vmin, vmax, offset, nb_ticks=5):
# If the threshold is very small compared to vmax, we use
# a simple linspace as the result would be very difficult to see.
ticks = np.linspace(vmin, vmax, nb_ticks)
if offset / vmax > 0.12:
if offset is not None and offset / vmax > 0.12:
diff = [abs(abs(tick) - offset) for tick in ticks]
# Edge case where the thresholds are exactly at
# the same distance to 4 ticks
Expand Down
8 changes: 7 additions & 1 deletion nilearn/plotting/surf_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import matplotlib.pyplot as plt
import numpy as np
import warnings

from matplotlib import gridspec
from matplotlib.colorbar import make_axes
Expand Down Expand Up @@ -359,9 +360,14 @@ def custom_function(vertices):
ticks = np.arange(vmin, vmax + 1)
nb_ticks = len(ticks)
else:
ticks = np.linspace(vmin, vmax, nb_ticks)
from nilearn.plotting.displays import _get_cbar_ticks
ticks = _get_cbar_ticks(vmin, vmax, threshold, nb_ticks)
bounds = np.linspace(vmin, vmax, our_cmap.N)
if threshold is not None:
if cbar_tick_format == "%i" and int(threshold) != threshold:
warnings.warn("You provided a non integer threshold "
"but configured the colorbar to use "
"integer formatting.")
cmaplist = [our_cmap(i) for i in range(our_cmap.N)]
# set colors to grey for absolute values < threshold
istart = int(norm(-threshold, clip=True) * (our_cmap.N - 1))
Expand Down

0 comments on commit eca1f35

Please sign in to comment.