code: def mathtext_to_wxbitmap(s):
      # We draw the text at position (0, 0) but then rely on
      # ``facecolor="none"`` and ``bbox_inches="tight", pad_inches=0`` to get a
      # transparent mask that is then loaded into a wx.Bitmap.
      fig = Figure(facecolor="none")
      text_color = (
          np.array(
              wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT)
          )
          / 255
      )
      fig.text(0, 0, s, fontsize=10, color=text_color)
      buf = BytesIO()
      fig.savefig(
          buf, format="png", dpi=150, bbox_inches="tight", pad_inches=0
      )
      s = buf.getvalue()
      return wx.Bitmap.NewFromPNGData(s, len(s))
  
file_path: matplotlib/galleries/examples/user_interfaces/mathtext_wx_sgskip.py
imports: from io import BytesIO
  import wx
  import numpy
  from matplotlib.backends.backend_wx import NavigationToolbar2Wx
  from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
  from matplotlib.figure import Figure
label_desc: Use image node_id 1 for calling a global function with example usage: mathtext_to_wxbitmap(s) and returns: wx