prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Ugly side plots in doc
  They mask part of the code they are supposed to illustrate. See an example [here](http://nilearn.github.io/building_blocks/data_preparation.html#computing-the-mask).
  
  ![ugly-side-plots](https://cloud.githubusercontent.com/assets/1680079/5974579/266c30d8-a876-11e4-8830-febff99ed1dc.png)
  
  
  </issue>
  <code>
  [start of examples/connectivity/plot_adhd_covariance.py]
  1 """
  2 Computation of covariance matrix between brain regions
  3 ======================================================
  4 
  5 This example shows how to extract signals from regions defined by an atlas,
  6 and to estimate a covariance matrix based on these signals.
  7 """
  8  
  9 plotted_subject = 0  # subject to plot
  10 
  11 
  12 import matplotlib.pyplot as plt
  13 import matplotlib
  14 # Copied from matplotlib 1.2.0 for matplotlib 0.99 compatibility.
  15 _bwr_data = ((0.0, 0.0, 1.0), (1.0, 1.0, 1.0), (1.0, 0.0, 0.0))
  16 plt.cm.register_cmap(cmap=matplotlib.colors.LinearSegmentedColormap.from_list(
  17     "bwr", _bwr_data))
  18 
  19 
  20 def plot_matrices(cov, prec, title):
  21     """Plot covariance and precision matrices, for a given processing. """
  22 
  23     prec = prec.copy()  # avoid side effects
  24 
  25     # Display sparsity pattern
  26     sparsity = prec == 0
  27     plt.figure()
  28     plt.imshow(sparsity, interpolation="nearest")
  29     plt.title("%s / sparsity" % title)
  30 
  31     # Put zeros on the diagonal, for graph clarity.
  32     size = prec.shape[0]
  33     prec[range(size), range(size)] = 0
  34     span = max(abs(prec.min()), abs(prec.max()))
  35 
  36     # Display covariance matrix
  37     plt.figure()
  38     plt.imshow(cov, interpolation="nearest",
  39               vmin=-1, vmax=1, cmap=plt.cm.get_cmap("bwr"))
  40     plt.colorbar()
  41     plt.title("%s / covariance" % title)
  42 
  43     # Display precision matrix
  44     plt.figure()
  45     plt.imshow(prec, interpolation="nearest",
  46               vmin=-span, vmax=span,
  47               cmap=plt.cm.get_cmap("bwr"))
  48     plt.colorbar()
  49     plt.title("%s / precision" % title)
  50 
  51 
  52 # Fetching datasets ###########################################################
  53 print("-- Fetching datasets ...")
  54 from nilearn import datasets
  55 msdl_atlas_dataset = datasets.fetch_msdl_atlas()
  56 adhd_dataset = datasets.fetch_adhd()
  57 
  58 # Extracting region signals ###################################################
  59 import nilearn.image
  60 import nilearn.input_data
  61 
  62 from sklearn.externals.joblib import Memory
  63 mem = Memory(".")
  64 
  65 # Number of subjects to consider for group-sparse covariance
  66 n_subjects = 10
  67 subjects = []
  68 
  69 func_filenames = adhd_dataset.func
  70 confound_filenames = adhd_dataset.confounds
  71 for func_filename, confound_filename in zip(func_filenames,
  72                                             confound_filenames):
  73     print("Processing file %s" % func_filename)
  74 
  75     print("-- Computing confounds ...")
  76     hv_confounds = mem.cache(nilearn.image.high_variance_confounds)(
  77         func_filename)
  78 
  79     print("-- Computing region signals ...")
  80     masker = nilearn.input_data.NiftiMapsMasker(
  81         msdl_atlas_dataset.maps, resampling_target="maps", detrend=True,
  82         low_pass=None, high_pass=0.01, t_r=2.5, standardize=True,
  83         memory=mem, memory_level=1, verbose=1)
  84     region_ts = masker.fit_transform(func_filename,
  85                                      confounds=[hv_confounds,
  86                                                 confound_filename])
  87     subjects.append(region_ts)
  88 
  89 # Computing group-sparse precision matrices ###################################
  90 print("-- Computing group-sparse precision matrices ...")
  91 from nilearn.group_sparse_covariance import GroupSparseCovarianceCV
  92 gsc = GroupSparseCovarianceCV(verbose=2, n_jobs=3)
  93 gsc.fit(subjects)
  94 
  95 print("-- Computing graph-lasso precision matrices ...")
  96 from sklearn import covariance
  97 gl = covariance.GraphLassoCV(n_jobs=3)
  98 gl.fit(subjects[plotted_subject])
  99 
  100 # Displaying results ##########################################################
  101 print("-- Displaying results")
  102 title = "{0:d} GroupSparseCovariance $\\alpha={1:.2e}$".format(plotted_subject,
  103                                                      gsc.alpha_)
  104 plot_matrices(gsc.covariances_[..., plotted_subject],
  105               gsc.precisions_[..., plotted_subject], title)
  106 
  107 title = "{0:d} GraphLasso $\\alpha={1:.2e}$".format(plotted_subject,
  108                                                      gl.alpha_)
  109 plot_matrices(gl.covariance_, gl.precision_, title)
  110 
  111 plt.show()
  112
  [end of examples/connectivity/plot_adhd_covariance.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/examples/connectivity/plot_adhd_covariance.py b/examples/connectivity/plot_adhd_covariance.py
  --- a/examples/connectivity/plot_adhd_covariance.py
  +++ b/examples/connectivity/plot_adhd_covariance.py
  @@ -20,13 +20,11 @@
   def plot_matrices(cov, prec, title):
       """Plot covariance and precision matrices, for a given processing. """
   
  +    # Compute sparsity pattern
  +    sparsity = (prec == 0)
  +    
       prec = prec.copy()  # avoid side effects
   
  -    # Display sparsity pattern
  -    sparsity = prec == 0
  -    plt.figure()
  -    plt.imshow(sparsity, interpolation="nearest")
  -    plt.title("%s / sparsity" % title)
   
       # Put zeros on the diagonal, for graph clarity.
       size = prec.shape[0]
  @@ -39,6 +37,11 @@
                 vmin=-1, vmax=1, cmap=plt.cm.get_cmap("bwr"))
       plt.colorbar()
       plt.title("%s / covariance" % title)
  +    
  +    # Display sparsity pattern
  +    plt.figure()
  +    plt.imshow(sparsity, interpolation="nearest")
  +    plt.title("%s / sparsity" % title)
   
       # Display precision matrix
       plt.figure()
  
verification_info: {"golden_diff": "diff --git a/examples/connectivity/plot_adhd_covariance.py b/examples/connectivity/plot_adhd_covariance.py\n--- a/examples/connectivity/plot_adhd_covariance.py\n+++ b/examples/connectivity/plot_adhd_covariance.py\n@@ -20,13 +20,11 @@\n def plot_matrices(cov, prec, title):\n     \"\"\"Plot covariance and precision matrices, for a given processing. \"\"\"\n \n+    # Compute sparsity pattern\n+    sparsity = (prec == 0)\n+    \n     prec = prec.copy()  # avoid side effects\n \n-    # Display sparsity pattern\n-    sparsity = prec == 0\n-    plt.figure()\n-    plt.imshow(sparsity, interpolation=\"nearest\")\n-    plt.title(\"%s / sparsity\" % title)\n \n     # Put zeros on the diagonal, for graph clarity.\n     size = prec.shape[0]\n@@ -39,6 +37,11 @@\n               vmin=-1, vmax=1, cmap=plt.cm.get_cmap(\"bwr\"))\n     plt.colorbar()\n     plt.title(\"%s / covariance\" % title)\n+    \n+    # Display sparsity pattern\n+    plt.figure()\n+    plt.imshow(sparsity, interpolation=\"nearest\")\n+    plt.title(\"%s / sparsity\" % title)\n \n     # Display precision matrix\n     plt.figure()\n", "issue": "Ugly side plots in doc\nThey mask part of the code they are supposed to illustrate. See an example [here](http://nilearn.github.io/building_blocks/data_preparation.html#computing-the-mask).\n\n![ugly-side-plots](https://cloud.githubusercontent.com/assets/1680079/5974579/266c30d8-a876-11e4-8830-febff99ed1dc.png)\n\n", "before_files": [{"content": "\"\"\"\nComputation of covariance matrix between brain regions\n======================================================\n\nThis example shows how to extract signals from regions defined by an atlas,\nand to estimate a covariance matrix based on these signals.\n\"\"\"\n \nplotted_subject = 0  # subject to plot\n\n\nimport matplotlib.pyplot as plt\nimport matplotlib\n# Copied from matplotlib 1.2.0 for matplotlib 0.99 compatibility.\n_bwr_data = ((0.0, 0.0, 1.0), (1.0, 1.0, 1.0), (1.0, 0.0, 0.0))\nplt.cm.register_cmap(cmap=matplotlib.colors.LinearSegmentedColormap.from_list(\n    \"bwr\", _bwr_data))\n\n\ndef plot_matrices(cov, prec, title):\n    \"\"\"Plot covariance and precision matrices, for a given processing. \"\"\"\n\n    prec = prec.copy()  # avoid side effects\n\n    # Display sparsity pattern\n    sparsity = prec == 0\n    plt.figure()\n    plt.imshow(sparsity, interpolation=\"nearest\")\n    plt.title(\"%s / sparsity\" % title)\n\n    # Put zeros on the diagonal, for graph clarity.\n    size = prec.shape[0]\n    prec[range(size), range(size)] = 0\n    span = max(abs(prec.min()), abs(prec.max()))\n\n    # Display covariance matrix\n    plt.figure()\n    plt.imshow(cov, interpolation=\"nearest\",\n              vmin=-1, vmax=1, cmap=plt.cm.get_cmap(\"bwr\"))\n    plt.colorbar()\n    plt.title(\"%s / covariance\" % title)\n\n    # Display precision matrix\n    plt.figure()\n    plt.imshow(prec, interpolation=\"nearest\",\n              vmin=-span, vmax=span,\n              cmap=plt.cm.get_cmap(\"bwr\"))\n    plt.colorbar()\n    plt.title(\"%s / precision\" % title)\n\n\n# Fetching datasets ###########################################################\nprint(\"-- Fetching datasets ...\")\nfrom nilearn import datasets\nmsdl_atlas_dataset = datasets.fetch_msdl_atlas()\nadhd_dataset = datasets.fetch_adhd()\n\n# Extracting region signals ###################################################\nimport nilearn.image\nimport nilearn.input_data\n\nfrom sklearn.externals.joblib import Memory\nmem = Memory(\".\")\n\n# Number of subjects to consider for group-sparse covariance\nn_subjects = 10\nsubjects = []\n\nfunc_filenames = adhd_dataset.func\nconfound_filenames = adhd_dataset.confounds\nfor func_filename, confound_filename in zip(func_filenames,\n                                            confound_filenames):\n    print(\"Processing file %s\" % func_filename)\n\n    print(\"-- Computing confounds ...\")\n    hv_confounds = mem.cache(nilearn.image.high_variance_confounds)(\n        func_filename)\n\n    print(\"-- Computing region signals ...\")\n    masker = nilearn.input_data.NiftiMapsMasker(\n        msdl_atlas_dataset.maps, resampling_target=\"maps\", detrend=True,\n        low_pass=None, high_pass=0.01, t_r=2.5, standardize=True,\n        memory=mem, memory_level=1, verbose=1)\n    region_ts = masker.fit_transform(func_filename,\n                                     confounds=[hv_confounds,\n                                                confound_filename])\n    subjects.append(region_ts)\n\n# Computing group-sparse precision matrices ###################################\nprint(\"-- Computing group-sparse precision matrices ...\")\nfrom nilearn.group_sparse_covariance import GroupSparseCovarianceCV\ngsc = GroupSparseCovarianceCV(verbose=2, n_jobs=3)\ngsc.fit(subjects)\n\nprint(\"-- Computing graph-lasso precision matrices ...\")\nfrom sklearn import covariance\ngl = covariance.GraphLassoCV(n_jobs=3)\ngl.fit(subjects[plotted_subject])\n\n# Displaying results ##########################################################\nprint(\"-- Displaying results\")\ntitle = \"{0:d} GroupSparseCovariance $\\\\alpha={1:.2e}$\".format(plotted_subject,\n                                                     gsc.alpha_)\nplot_matrices(gsc.covariances_[..., plotted_subject],\n              gsc.precisions_[..., plotted_subject], title)\n\ntitle = \"{0:d} GraphLasso $\\\\alpha={1:.2e}$\".format(plotted_subject,\n                                                     gl.alpha_)\nplot_matrices(gl.covariance_, gl.precision_, title)\n\nplt.show()\n", "path": "examples/connectivity/plot_adhd_covariance.py"}]}