prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Plots won't show up
  Hi everyone,
  
  using nilearn on OSX El Capitan, when executing the example scripts like plot_demo_glass_brain.py no plots will show up. PiP and iPython linked to the same folders, matplotlib alone does show plots. All dependencies are up-to-date and installed. Don't really know how to fix this.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `nilearn/plotting/__init__.py`
  Content:
  ```
  1 """
  2 Plotting code for nilearn
  3 """
  4 # Authors: Chris Filo Gorgolewski, Gael Varoquaux
  5 
  6 ###############################################################################
  7 # Make sure that we don't get DISPLAY problems when running without X on
  8 # unices
  9 def _set_mpl_backend():
  10     try:
  11         # We are doing local imports here to avoid poluting our namespace
  12         import matplotlib
  13         import os
  14         # Set the backend to a non-interactive one for unices without X
  15         if os.name == 'posix' and 'DISPLAY' not in os.environ:
  16             matplotlib.use('Agg')
  17     except ImportError:
  18         from .._utils.testing import skip_if_running_nose
  19         # No need to fail when running tests
  20         skip_if_running_nose('matplotlib not installed')
  21         raise
  22     else:
  23         from ..version import (_import_module_with_version_check,
  24                                OPTIONAL_MATPLOTLIB_MIN_VERSION)
  25         # When matplotlib was successfully imported we need to check
  26         # that the version is greater that the minimum required one
  27         _import_module_with_version_check('matplotlib',
  28                                           OPTIONAL_MATPLOTLIB_MIN_VERSION)
  29 
  30 _set_mpl_backend()
  31 
  32 ###############################################################################
  33 
  34 from . import cm
  35 from .img_plotting import plot_img, plot_anat, plot_epi, \
  36     plot_roi, plot_stat_map, plot_glass_brain, plot_connectome, \
  37     plot_prob_atlas, show
  38 from .find_cuts import find_xyz_cut_coords, find_cut_slices
  39 
  40 __all__ = ['cm', 'plot_img', 'plot_anat', 'plot_epi',
  41            'plot_roi', 'plot_stat_map', 'plot_glass_brain',
  42            'plot_connectome', 'plot_prob_atlas',
  43            'find_xyz_cut_coords', 'find_cut_slices',
  44            'show']
  45
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/nilearn/plotting/__init__.py b/nilearn/plotting/__init__.py
  --- a/nilearn/plotting/__init__.py
  +++ b/nilearn/plotting/__init__.py
  @@ -11,8 +11,12 @@
           # We are doing local imports here to avoid poluting our namespace
           import matplotlib
           import os
  +        import sys
           # Set the backend to a non-interactive one for unices without X
  -        if os.name == 'posix' and 'DISPLAY' not in os.environ:
  +        if (os.name == 'posix' and 'DISPLAY' not in os.environ
  +            and not (sys.platform == 'darwin'
  +                     and matplotlib.get_backend() == 'MacOSX'
  +                     )):
               matplotlib.use('Agg')
       except ImportError:
           from .._utils.testing import skip_if_running_nose
  
verification_info: {"golden_diff": "diff --git a/nilearn/plotting/__init__.py b/nilearn/plotting/__init__.py\n--- a/nilearn/plotting/__init__.py\n+++ b/nilearn/plotting/__init__.py\n@@ -11,8 +11,12 @@\n         # We are doing local imports here to avoid poluting our namespace\n         import matplotlib\n         import os\n+        import sys\n         # Set the backend to a non-interactive one for unices without X\n-        if os.name == 'posix' and 'DISPLAY' not in os.environ:\n+        if (os.name == 'posix' and 'DISPLAY' not in os.environ\n+            and not (sys.platform == 'darwin'\n+                     and matplotlib.get_backend() == 'MacOSX'\n+                     )):\n             matplotlib.use('Agg')\n     except ImportError:\n         from .._utils.testing import skip_if_running_nose\n", "issue": "Plots won't show up\nHi everyone,\n\nusing nilearn on OSX El Capitan, when executing the example scripts like plot_demo_glass_brain.py no plots will show up. PiP and iPython linked to the same folders, matplotlib alone does show plots. All dependencies are up-to-date and installed. Don't really know how to fix this.\n\n", "before_files": [{"content": "\"\"\"\nPlotting code for nilearn\n\"\"\"\n# Authors: Chris Filo Gorgolewski, Gael Varoquaux\n\n###############################################################################\n# Make sure that we don't get DISPLAY problems when running without X on\n# unices\ndef _set_mpl_backend():\n    try:\n        # We are doing local imports here to avoid poluting our namespace\n        import matplotlib\n        import os\n        # Set the backend to a non-interactive one for unices without X\n        if os.name == 'posix' and 'DISPLAY' not in os.environ:\n            matplotlib.use('Agg')\n    except ImportError:\n        from .._utils.testing import skip_if_running_nose\n        # No need to fail when running tests\n        skip_if_running_nose('matplotlib not installed')\n        raise\n    else:\n        from ..version import (_import_module_with_version_check,\n                               OPTIONAL_MATPLOTLIB_MIN_VERSION)\n        # When matplotlib was successfully imported we need to check\n        # that the version is greater that the minimum required one\n        _import_module_with_version_check('matplotlib',\n                                          OPTIONAL_MATPLOTLIB_MIN_VERSION)\n\n_set_mpl_backend()\n\n###############################################################################\n\nfrom . import cm\nfrom .img_plotting import plot_img, plot_anat, plot_epi, \\\n    plot_roi, plot_stat_map, plot_glass_brain, plot_connectome, \\\n    plot_prob_atlas, show\nfrom .find_cuts import find_xyz_cut_coords, find_cut_slices\n\n__all__ = ['cm', 'plot_img', 'plot_anat', 'plot_epi',\n           'plot_roi', 'plot_stat_map', 'plot_glass_brain',\n           'plot_connectome', 'plot_prob_atlas',\n           'find_xyz_cut_coords', 'find_cut_slices',\n           'show']\n", "path": "nilearn/plotting/__init__.py"}], "after_files": [{"content": "\"\"\"\nPlotting code for nilearn\n\"\"\"\n# Authors: Chris Filo Gorgolewski, Gael Varoquaux\n\n###############################################################################\n# Make sure that we don't get DISPLAY problems when running without X on\n# unices\ndef _set_mpl_backend():\n    try:\n        # We are doing local imports here to avoid poluting our namespace\n        import matplotlib\n        import os\n        import sys\n        # Set the backend to a non-interactive one for unices without X\n        if (os.name == 'posix' and 'DISPLAY' not in os.environ\n            and not (sys.platform == 'darwin'\n                     and matplotlib.get_backend() == 'MacOSX'\n                     )):\n            matplotlib.use('Agg')\n    except ImportError:\n        from .._utils.testing import skip_if_running_nose\n        # No need to fail when running tests\n        skip_if_running_nose('matplotlib not installed')\n        raise\n    else:\n        from ..version import (_import_module_with_version_check,\n                               OPTIONAL_MATPLOTLIB_MIN_VERSION)\n        # When matplotlib was successfully imported we need to check\n        # that the version is greater that the minimum required one\n        _import_module_with_version_check('matplotlib',\n                                          OPTIONAL_MATPLOTLIB_MIN_VERSION)\n\n_set_mpl_backend()\n\n###############################################################################\n\nfrom . import cm\nfrom .img_plotting import plot_img, plot_anat, plot_epi, \\\n    plot_roi, plot_stat_map, plot_glass_brain, plot_connectome, \\\n    plot_prob_atlas, show\nfrom .find_cuts import find_xyz_cut_coords, find_cut_slices\n\n__all__ = ['cm', 'plot_img', 'plot_anat', 'plot_epi',\n           'plot_roi', 'plot_stat_map', 'plot_glass_brain',\n           'plot_connectome', 'plot_prob_atlas',\n           'find_xyz_cut_coords', 'find_cut_slices',\n           'show']\n", "path": "nilearn/plotting/__init__.py"}]}