Repository: nilearn/nilearn

Issue:
image generated by `plot_surf_stat_map` has different aspect when saved in png vs pdf
<!--Provide a brief description of the bug.-->
The aspect of a saved 3d image depends on whether it was saved as pdf or png.
Could be a matplotlib bug.

<!--Please fill in the following information, to the best of your ability.-->

### Expected behavior
The images should be identical

### Steps and code to reproduce bug

<!-- Please ensure the code is a minimal runnable example using Nilearn data to showcase it. -->
<!-- https://stackoverflow.com/help/minimal-reproducible-example -->

```python
from nilearn import datasets
from nilearn import surface
from nilearn import plotting

motor_images = datasets.fetch_neurovault_motor_task()
stat_img = motor_images.images[0]
fsaverage = datasets.fetch_surf_fsaverage()
texture = surface.vol_to_surf(stat_img, fsaverage.pial_right)

output_file = '/tmp/plop.pdf'
fig = plotting.plot_surf_stat_map(
    fsaverage.infl_right, texture, hemi='right',
    threshold=1., bg_map=fsaverage.sulc_right,
    output_file=output_file
)

output_file = '/tmp/plop.png'
fig = plotting.plot_surf_stat_map(
    fsaverage.infl_right, texture, hemi='right',
    threshold=1., bg_map=fsaverage.sulc_right,
    output_file=output_file
)
```



Discussion:
Hi @bthirion I do see a difference in the shadings that might be related to the quality. I think this is inherent in the file type but I do not know much about it.
If you meant the aspect ratio, I do not see a difference in that. (Sorry if I misunderstand the terminology!)
Hi, same for me -- the pdf brain is transparent whereas the other one is not. aspect ratio seems the same. do these plots look like the ones you obtained @bthirion ?

![plop](https://user-images.githubusercontent.com/9196501/213671279-3ec8c18c-7dd8-460d-911e-acbac1df687a.png)

[plop.pdf](https://github.com/nilearn/nilearn/files/10465344/plop.pdf)

If the difference is the transparency of the background map, we are planning to get rid of that anyway as discussed in #3173 
I guess the bug is that the brain is transparent (and we see the wireframe) in the pdf image, even when we specify alpha=1 and it should be completely opaque? 
![screenshot_2023-01-20T07:22:25-03:00](https://user-images.githubusercontent.com/9196501/213672480-94b185f7-345f-4077-a07d-5d9236076a6f.png)

it seems like the triangles are opaque (as they should be), but we actually see through the edges/interstices between the triangles. we should probably look into how we can give a color to the wireframe edges, or set their width?

> Hi, same for me -- the pdf brain is transparent whereas the other one is not. aspect ratio seems the same. do these plots look like the ones you obtained @bthirion ?
> 
> ![plop](https://user-images.githubusercontent.com/9196501/213671279-3ec8c18c-7dd8-460d-911e-acbac1df687a.png)
> 
> [plop.pdf](https://github.com/nilearn/nilearn/files/10465344/plop.pdf)
> 
> If the difference is the transparency of the background map, we are planning to get rid of that anyway as discussed in #3173

OK, thx.
I can look into this

Resolving patch:
diff --git a/nilearn/plotting/surf_plotting.py b/nilearn/plotting/surf_plotting.py
--- a/nilearn/plotting/surf_plotting.py
+++ b/nilearn/plotting/surf_plotting.py
@@ -550,7 +550,7 @@ def _plot_surf_matplotlib(coords, faces, surf_map=None, bg_map=None,
 
     # plot mesh without data
     p3dcollec = axes.plot_trisurf(coords[:, 0], coords[:, 1], coords[:, 2],
-                                  triangles=faces, linewidth=0.,
+                                  triangles=faces, linewidth=0.1,
                                   antialiased=False,
                                   color='white')
 
@@ -600,6 +600,7 @@ def _plot_surf_matplotlib(coords, faces, surf_map=None, bg_map=None,
                 format=cbar_tick_format, orientation='vertical')
 
         p3dcollec.set_facecolors(face_colors)
+        p3dcollec.set_edgecolors(face_colors)
 
     if title is not None:
         axes.set_title(title)


Test patch: