code: def test_plot_surf_stat_map_matplotlib_specific(rng):
      mesh = generate_surf()
      data = 10 * rng.standard_normal(size=mesh[0].shape[0])
      # Plot to axes
      axes = plt.subplots(ncols=2, subplot_kw={"projection": "3d"})[1]
      for ax in axes.flatten():
          plot_surf_stat_map(mesh, stat_map=data, ax=ax)
      axes = plt.subplots(ncols=2, subplot_kw={"projection": "3d"})[1]
      for ax in axes.flatten():
          plot_surf_stat_map(mesh, stat_map=data, ax=ax, colorbar=True)
  
      fig = plot_surf_stat_map(mesh, stat_map=data, colorbar=False)
      assert len(fig.axes) == 1
  
      # symmetric_cbar
      fig = plot_surf_stat_map(
          mesh, stat_map=data, colorbar=True, symmetric_cbar=True
      )
      fig.canvas.draw()
      assert len(fig.axes) == 2
      yticklabels = fig.axes[1].get_yticklabels()
      first, last = (
          yticklabels[0].get_text(),
          yticklabels[-1].get_text(),
      )
      assert float(first) == -float(last)
  
      # no symmetric_cbar
      fig = plot_surf_stat_map(
          mesh, stat_map=data, colorbar=True, symmetric_cbar=False
      )
      fig.canvas.draw()
      assert len(fig.axes) == 2
      yticklabels = fig.axes[1].get_yticklabels()
      first, last = (
          yticklabels[0].get_text(),
          yticklabels[-1].get_text(),
      )
      assert float(first) != -float(last)
  
      # Test handling of nan values in texture data
      # Add nan values in the texture
      data[2] = np.nan
      # Plot the surface stat map
      fig = plot_surf_stat_map(mesh, stat_map=data)
      # Check that the resulting plot facecolors contain no transparent faces
      # (last column equals zero) even though the texture contains nan values
      tmp = fig._axstack.as_list()[0].collections[0]
      assert mesh[1].shape[0] == ((tmp._facecolors[:, 3]) != 0).sum()
  
      # Save execution time and memory
      plt.close()
  
imports: import re
  import tempfile
  import unittest.mock
  import matplotlib.pyplot
  import numpy
  import pytest
  from matplotlib.figure import Figure
  from numpy.testing import assert_array_equal
  from nilearn._utils.helpers import is_kaleido_installed, is_plotly_installed
  from nilearn.conftest import _rng
  from nilearn.datasets import fetch_surf_fsaverage
  from nilearn.plotting.displays import PlotlySurfaceFigure
  from nilearn.plotting.surf_plotting import VALID_HEMISPHERES, VALID_VIEWS, _compute_facecolors_matplotlib, _get_ticks_matplotlib, _get_view_plot_surf_matplotlib, _get_view_plot_surf_plotly, plot_img_on_surf, plot_surf, plot_surf_contours, plot_surf_roi, plot_surf_stat_map
  from nilearn.surface import load_surf_data, load_surf_mesh
  from nilearn.surface.tests._testing import generate_surf
label_desc: Use image node_id 23 for calling a global function with example usage: test_plot_surf_stat_map_matplotlib_specific(rng) without return types