.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/01_plotting/plot_dim_plotting.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_auto_examples_01_plotting_plot_dim_plotting.py>`
        to download the full example code or to run this example in your browser via Binder

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_01_plotting_plot_dim_plotting.py:


Controlling the contrast of the background when plotting
=========================================================

The `dim` argument controls the contrast of the background.

*dim* modifies the contrast of this image: dim=0 leaves the image
unchanged, negative values of *dim* enhance it, and positive values
decrease it (dim the background).

This *dim* argument may also be useful for the plot_roi function used to
display ROIs on top of a background image.

.. GENERATED FROM PYTHON SOURCE LINES 17-19

Retrieve the data: the localizer dataset with contrast maps
------------------------------------------------------------

.. GENERATED FROM PYTHON SOURCE LINES 19-28

.. code-block:: default


    from nilearn import datasets

    localizer_dataset = datasets.fetch_localizer_button_task(legacy_format=False)
    # Contrast map of motor task
    localizer_tmap_filename = localizer_dataset.tmap
    # Subject specific anatomical image
    localizer_anat_filename = localizer_dataset.anat








.. GENERATED FROM PYTHON SOURCE LINES 29-31

Plotting with enhancement of background image with dim=-.5
--------------------------------------------------------------------------

.. GENERATED FROM PYTHON SOURCE LINES 31-39

.. code-block:: default


    from nilearn import plotting
    plotting.plot_stat_map(localizer_tmap_filename,
                           bg_img=localizer_anat_filename,
                           cut_coords=(36, -27, 66),
                           threshold=3, title="dim=-.5",
                           dim=-.5)




.. image-sg:: /auto_examples/01_plotting/images/sphx_glr_plot_dim_plotting_001.png
   :alt: plot dim plotting
   :srcset: /auto_examples/01_plotting/images/sphx_glr_plot_dim_plotting_001.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none


    <nilearn.plotting.displays._slicers.OrthoSlicer object at 0x7f9df0bd0c40>



.. GENERATED FROM PYTHON SOURCE LINES 40-42

Plotting with no change of contrast in background image with dim=0
-------------------------------------------------------------------

.. GENERATED FROM PYTHON SOURCE LINES 42-48

.. code-block:: default

    plotting.plot_stat_map(localizer_tmap_filename,
                           bg_img=localizer_anat_filename,
                           cut_coords=(36, -27, 66),
                           threshold=3, title="dim=0",
                           dim=0)




.. image-sg:: /auto_examples/01_plotting/images/sphx_glr_plot_dim_plotting_002.png
   :alt: plot dim plotting
   :srcset: /auto_examples/01_plotting/images/sphx_glr_plot_dim_plotting_002.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none


    <nilearn.plotting.displays._slicers.OrthoSlicer object at 0x7f9e1204d070>



.. GENERATED FROM PYTHON SOURCE LINES 49-51

Plotting with decrease of contrast in background image with dim=.5
-------------------------------------------------------------------

.. GENERATED FROM PYTHON SOURCE LINES 51-57

.. code-block:: default

    plotting.plot_stat_map(localizer_tmap_filename,
                           bg_img=localizer_anat_filename,
                           cut_coords=(36, -27, 66),
                           threshold=3, title="dim=.5",
                           dim=.5)




.. image-sg:: /auto_examples/01_plotting/images/sphx_glr_plot_dim_plotting_003.png
   :alt: plot dim plotting
   :srcset: /auto_examples/01_plotting/images/sphx_glr_plot_dim_plotting_003.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none


    <nilearn.plotting.displays._slicers.OrthoSlicer object at 0x7f9e05135be0>



.. GENERATED FROM PYTHON SOURCE LINES 58-60

Plotting with more decrease in contrast with dim=1
---------------------------------------------------

.. GENERATED FROM PYTHON SOURCE LINES 60-67

.. code-block:: default

    plotting.plot_stat_map(localizer_tmap_filename,
                           bg_img=localizer_anat_filename,
                           cut_coords=(36, -27, 66),
                           threshold=3, title="dim=1",
                           dim=1)

    plotting.show()



.. image-sg:: /auto_examples/01_plotting/images/sphx_glr_plot_dim_plotting_004.png
   :alt: plot dim plotting
   :srcset: /auto_examples/01_plotting/images/sphx_glr_plot_dim_plotting_004.png
   :class: sphx-glr-single-img






.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  5.807 seconds)

**Estimated memory usage:**  9 MB


.. _sphx_glr_download_auto_examples_01_plotting_plot_dim_plotting.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example


  .. container:: binder-badge

    .. image:: images/binder_badge_logo.svg
      :target: https://mybinder.org/v2/gh/nilearn/nilearn.github.io/main?filepath=examples/auto_examples/01_plotting/plot_dim_plotting.ipynb
      :alt: Launch binder
      :width: 150 px


  .. container:: sphx-glr-download sphx-glr-download-python

     :download:`Download Python source code: plot_dim_plotting.py <plot_dim_plotting.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: plot_dim_plotting.ipynb <plot_dim_plotting.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_