Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.
8.10.32. nilearn.plotting.displays.OrthoSlicer¶
- class
nilearn.plotting.displays.
OrthoSlicer
(cut_coords, axes=None, black_bg=False, brain_color=(0.5, 0.5, 0.5), **kwargs)¶ A class to create 3 linked axes for plotting orthogonal cuts of 3D maps.
Notes
The extent of the different axes are adjusted to fit the data best in the viewing area.
- Attributes
- axesdictionary of axes
The 3 axes used to plot each view.
- frame_axesaxes
The axes framing the whole set of views.
__init__
(cut_coords, axes=None, black_bg=False, brain_color=(0.5, 0.5, 0.5), **kwargs)¶Create 3 linked axes for plotting orthogonal cuts.
- Parameters
- cut_coords3 tuple of ints
The cut position, in world space.
- axesmatplotlib axes object, optional
The axes that will be subdivided in 3.
- black_bgboolean, optional
If True, the background of the figure will be put to black. If you wish to save figures with a black background, you will need to pass “facecolor=’k’, edgecolor=’k’” to matplotlib.pyplot.savefig. Default=False.
- brain_colortuple, optional
The brain color to use as the background color (e.g., for transparent colorbars). Default=(0.5, 0.5, 0.5)
- classmethod
find_cut_coords
(img=None, threshold=None, cut_coords=None)¶ Instantiate the slicer and find cut coordinates
draw_cross
(cut_coords=None, **kwargs)¶Draw a crossbar on the plot to show where the cut is performed.
- Parameters
- cut_coords3-tuple of floats, optional
The position of the cross to draw. If none is passed, the ortho_slicer’s cut coordinates are used.
- kwargs :
Extra keyword arguments are passed to axhline
add_contours
(img, threshold=1e-06, filled=False, **kwargs)¶Contour a 3D map in all the views.
- Parameters
- imgNiimg-like object
See http://nilearn.github.io/manipulating_images/input_output.html Provides image to plot.
- thresholdInt or Float or None, optional
If None is given, the maps are not thresholded. If a number is given, it is used to threshold the maps, values below the threshold (in absolute value) are plotted as transparent. Default=1e-6.
- filledboolean, optional
If filled=True, contours are displayed with color fillings. Default=False.
- kwargs :
Extra keyword arguments are passed to contour, see the documentation of pylab.contour and see pylab.contourf documentation for arguments related to contours with fillings. Useful, arguments are typical “levels”, which is a list of values to use for plotting a contour or contour fillings (if filled=True), and “colors”, which is one color or a list of colors for these contours.
Notes
If colors are not specified, default coloring choices (from matplotlib) for contours and contour_fillings can be different.
add_edges
(img, color='r')¶Plot the edges of a 3D map in all the views.
- Parameters
- imgNiimg-like object
See http://nilearn.github.io/manipulating_images/input_output.html The 3D map to be plotted. If it is a masked array, only the non-masked part will be plotted.
- colormatplotlib color: string or (r, g, b) value
The color used to display the edge map. Default=’r’.
add_markers
(marker_coords, marker_color='r', marker_size=30, **kwargs)¶Add markers to the plot.
- Parameters
- marker_coordsarray of size (n_markers, 3)
Coordinates of the markers to plot. For each slice, only markers that are 2 millimeters away from the slice are plotted.
- marker_colorpyplot compatible color or list of shape (n_markers,), optional
List of colors for each marker that can be string or matplotlib colors. Default=’r’.
- marker_sizesingle float or list of shape (n_markers,), optional
Size in pixel for each marker. Default=30.
add_overlay
(img, threshold=1e-06, colorbar=False, **kwargs)¶Plot a 3D map in all the views.
- Parameters
- imgNiimg-like object
See http://nilearn.github.io/manipulating_images/input_output.html If it is a masked array, only the non-masked part will be plotted.
- thresholdInt or Float or None, optional
If None is given, the maps are not thresholded. If a number is given, it is used to threshold the maps: values below the threshold (in absolute value) are plotted as transparent. Default=1e-6.
- colorbarboolean, optional
If True, display a colorbar on the right of the plots. Default=False.
- kwargs :
Extra keyword arguments are passed to imshow.
annotate
(left_right=True, positions=True, scalebar=False, size=12, scale_size=5.0, scale_units='cm', scale_loc=4, decimals=0, **kwargs)¶Add annotations to the plot.
- Parameters
- left_rightboolean, optional
If left_right is True, annotations indicating which side is left and which side is right are drawn. Default=True.
- positionsboolean, optional
If positions is True, annotations indicating the positions of the cuts are drawn. Default=True.
- scalebarboolean, optional
If
True
, cuts are annotated with a reference scale bar. For finer control of the scale bar, please check out the draw_scale_bar method on the axes in “axes” attribute of this object. Default=False.- sizeinteger, optional
The size of the text used. Default=12.
- scale_sizenumber, optional
The length of the scalebar, in units of scale_units. Default=5.0.
- scale_units{‘cm’, ‘mm’}, optional
The units for the scalebar. Default=’cm’.
- scale_locinteger, optional
The positioning for the scalebar. Default=4. Valid location codes are:
‘upper right’ : 1
‘upper left’ : 2
‘lower left’ : 3
‘lower right’ : 4
‘right’ : 5
‘center left’ : 6
‘center right’ : 7
‘lower center’ : 8
‘upper center’ : 9
‘center’ : 10
- decimalsinteger, optional
Number of decimal places on slice position annotation. If zero, the slice position is integer without decimal point. Default=0.
- kwargs :
Extra keyword arguments are passed to matplotlib’s text function.
close
()¶Close the figure. This is necessary to avoid leaking memory.
- classmethod
init_with_figure
(img, threshold=None, cut_coords=None, figure=None, axes=None, black_bg=False, leave_space=False, colorbar=False, brain_color=(0.5, 0.5, 0.5), **kwargs)¶ Initialize the slicer with an image
savefig
(filename, dpi=None)¶Save the figure to a file
- Parameters
- filenamestring
The file name to save to. Its extension determines the file type, typically ‘.png’, ‘.svg’ or ‘.pdf’.
- dpiNone or scalar, optional
The resolution in dots per inch.
title
(text, x=0.01, y=0.99, size=15, color=None, bgcolor=None, alpha=1, **kwargs)¶Write a title to the view.
- Parameters
- textstring
The text of the title.
- xfloat, optional
The horizontal position of the title on the frame in fraction of the frame width. Default=0.01.
- yfloat, optional
The vertical position of the title on the frame in fraction of the frame height. Default=0.99.
- sizeinteger, optional
The size of the title text. Default=15.
- colormatplotlib color specifier, optional
The color of the font of the title.
- bgcolormatplotlib color specifier, optional
The color of the background of the title.
- alphafloat, optional
The alpha value for the background. Default=1.
- kwargs :
Extra keyword arguments are passed to matplotlib’s text function.