code: def _categorical_legend(m, title, categories, colors):
      """
      Add categorical legend to a map
  
      The implementation is using the code originally written by Michel Metran
      (@michelmetran) and released on GitHub
      (https://github.com/michelmetran/package_folium) under MIT license.
  
      Copyright (c) 2020 Michel Metran
  
      Parameters
      ----------
      m : folium.Map
          Existing map instance on which to draw the plot
      title : str
          title of the legend (e.g. column name)
      categories : list-like
          list of categories
      colors : list-like
          list of colors (in the same order as categories)
      """
  
      # Header to Add
      head = """
      {% macro header(this, kwargs) %}
      <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
      <script>$( function() {
          $( ".maplegend" ).draggable({
              start: function (event, ui) {
                  $(this).css({
                      right: "auto",
                      top: "auto",
                      bottom: "auto"
                  });
              }
          });
      });
      </script>
      <style type='text/css'>
        .maplegend {
          position: absolute;
          z-index:9999;
          background-color: rgba(255, 255, 255, .8);
          border-radius: 5px;
          box-shadow: 0 0 15px rgba(0,0,0,0.2);
          padding: 10px;
          font: 12px/14px Arial, Helvetica, sans-serif;
          right: 10px;
          bottom: 20px;
        }
        .maplegend .legend-title {
          text-align: left;
          margin-bottom: 5px;
          font-weight: bold;
          }
        .maplegend .legend-scale ul {
          margin: 0;
          margin-bottom: 0px;
          padding: 0;
          float: left;
          list-style: none;
          }
        .maplegend .legend-scale ul li {
          list-style: none;
          margin-left: 0;
          line-height: 16px;
          margin-bottom: 2px;
          }
        .maplegend ul.legend-labels li span {
          display: block;
          float: left;
          height: 14px;
          width: 14px;
          margin-right: 5px;
          margin-left: 0;
          border: 0px solid #ccc;
          }
        .maplegend .legend-source {
          color: #777;
          clear: both;
          }
        .maplegend a {
          color: #777;
          }
      </style>
      {% endmacro %}
      """
      import branca as bc
  
      # Add CSS (on Header)
      macro = bc.element.MacroElement()
      macro._template = bc.element.Template(head)
      m.get_root().add_child(macro)
  
      body = f"""
      <div id='maplegend {title}' class='maplegend'>
          <div class='legend-title'>{title}</div>
          <div class='legend-scale'>
              <ul class='legend-labels'>"""
  
      # Loop Categories
      for label, color in zip(categories, colors):
          body += f"""
                  <li><span style='background:{color}'></span>{label}</li>"""
  
      body += """
              </ul>
          </div>
      </div>
      """
  
      # Add Body
      body = bc.element.Element(body, "legend")
      m.get_root().html.add_child(body)
  
file_path: geopandas/geopandas/explore.py
imports: from statistics import mean
  import geopandas
  from shapely.geometry import LineString
  import numpy
  import pandas
  from packaging.version import Version
label_desc: Use image node_id 3 for calling a global function with example usage: _categorical_legend(m, title, categories, colors) without return types