docs: def Beachball(fm, linewidth=2, facecolor='b', bgcolor='w', edgecolor='k',
                alpha=1.0, xy=(0, 0), width=200, size=100, nofill=False,
                zorder=100, outfile=None, format=None, fig=None):
      """
      Draws a beach ball diagram of an earthquake focal mechanism.
  
      S1, D1, and R1, the strike, dip and rake of one of the focal planes, can
      be vectors of multiple focal mechanisms.
  
      :param fm: Focal mechanism that is either number of mechanisms (NM) by 3
          (strike, dip, and rake) or NM x 6 (M11, M22, M33, M12, M13, M23 - the
          six independent components of the moment tensor, where the coordinate
          system is 1,2,3 = Up,South,East which equals r,theta,phi). The strike
          is of the first plane, clockwise relative to north.
          The dip is of the first plane, defined clockwise and perpendicular to
          strike, relative to horizontal such that 0 is horizontal and 90 is
          vertical. The rake is of the first focal plane solution. 90 moves the
          hanging wall up-dip (thrust), 0 moves it in the strike direction
          (left-lateral), -90 moves it down-dip (normal), and 180 moves it
          opposite to strike (right-lateral).
      :param facecolor: Color to use for quadrants of tension; can be a string,
          e.g. ``'r'``, ``'b'`` or three component color vector, [R G B].
          Defaults to ``'b'`` (blue).
      :param bgcolor: The background color. Defaults to ``'w'`` (white).
      :param edgecolor: Color of the edges. Defaults to ``'k'`` (black).
      :param alpha: The alpha level of the beach ball. Defaults to ``1.0``
          (opaque).
      :param xy: Origin position of the beach ball as tuple. Defaults to
          ``(0, 0)``.
      :type width: int
      :param width: Symbol size of beach ball. Defaults to ``200``.
      :param size: Controls the number of interpolation points for the
          curves. Minimum is automatically set to ``100``.
      :param nofill: Do not fill the beach ball, but only plot the planes.
      :param zorder: Set zorder. Artists with lower zorder values are drawn
          first.
      :param outfile: Output file string. Also used to automatically
          determine the output format. Supported file formats depend on your
          matplotlib backend. Most backends support png, pdf, ps, eps and
          svg. Defaults to ``None``.
      :param format: Format of the graph picture. If no format is given the
          outfile parameter will be used to try to automatically determine
          the output format. If no format is found it defaults to png output.
          If no outfile is specified but a format is, than a binary
          imagestring will be returned.
          Defaults to ``None``.
      :param fig: Give an existing figure instance to plot into. New Figure if
          set to ``None``.
      """
      plot_width = width * 0.95
  
      # plot the figure
      if not fig:
          fig = plt.figure(figsize=(3, 3), dpi=100)
          fig.subplots_adjust(left=0, bottom=0, right=1, top=1)
          fig.set_figheight(width // 100)
          fig.set_figwidth(width // 100)
      ax = fig.add_subplot(111, aspect='equal')
  
      # hide axes + ticks
      ax.axison = False
  
      # plot the collection
      collection = Beach(fm, linewidth=linewidth, facecolor=facecolor,
                         edgecolor=edgecolor, bgcolor=bgcolor,
                         alpha=alpha, nofill=nofill, xy=xy,
                         width=plot_width, size=size, zorder=zorder)
      ax.add_collection(collection)
  
      ax.autoscale_view(tight=False, scalex=True, scaley=True)
      # export
      if outfile:
          if format:
              fig.savefig(outfile, dpi=100, transparent=True, format=format)
          else:
              fig.savefig(outfile, dpi=100, transparent=True)
      elif format and not outfile:
          imgdata = compatibility.BytesIO()
          fig.savefig(imgdata, format=format, dpi=100, transparent=True)
          imgdata.seek(0)
          return imgdata.read()
      else:
          plt.show()
          return fig