code: def test_colorbar(self):
      def quoted_in(find, s):
          return find in s or find.replace("'", '"') in s
  
      m = self.world.explore("range", legend=True)
      out_str = self._fetch_map_string(m)
      assert "attr(\"id\",'legend')" in out_str
      assert quoted_in("text('range')", out_str)
  
      m = self.world.explore(
          "range", legend=True, legend_kwds={"caption": "my_caption"}
      )
      out_str = self._fetch_map_string(m)
      assert "attr(\"id\",'legend')" in out_str
      assert quoted_in("text('my_caption')", out_str)
  
      m = self.missing.explore(
          "pop_est", legend=True, missing_kwds={"color": "red"}
      )
      out_str = self._fetch_map_string(m)
      assert "red'></span>NaN" in out_str
  
      # do not scale legend
      m = self.world.explore(
          "pop_est",
          legend=True,
          legend_kwds={"scale": False},
          scheme="Headtailbreaks",
      )
      out_str = self._fetch_map_string(m)
      assert out_str.count("#440154ff") == 100
      assert out_str.count("#3b528bff") == 100
      assert out_str.count("#21918cff") == 100
      assert out_str.count("#5ec962ff") == 100
      assert out_str.count("#fde725ff") == 100
  
      # scale legend accordingly
      m = self.world.explore(
          "pop_est",
          legend=True,
          scheme="Headtailbreaks",
      )
      out_str = self._fetch_map_string(m)
      assert out_str.count("#440154ff") == 16
      assert out_str.count("#3b528bff") == 50
      assert out_str.count("#21918cff") == 138
      assert out_str.count("#5ec962ff") == 290
      assert out_str.count("#fde725ff") == 6
  
      # discrete cmap
      m = self.world.explore("pop_est", legend=True, cmap="Pastel2")
      out_str = self._fetch_map_string(m)
  
      assert out_str.count("b3e2cdff") == 63
      assert out_str.count("fdcdacff") == 62
      assert out_str.count("cbd5e8ff") == 63
      assert out_str.count("f4cae4ff") == 62
      assert out_str.count("e6f5c9ff") == 62
      assert out_str.count("fff2aeff") == 63
      assert out_str.count("f1e2ccff") == 62
      assert out_str.count("ccccccff") == 63
  
imports: import geopandas
  import numpy
  import pandas
  import pytest
  import shapely
  from packaging.version import Version
  from matplotlib import cm
  from matplotlib import colors
  from branca.colormap import StepColormap
label_desc: Use image node_id 23 for calling the TestExplore obj's underlying member method code with example usage: obj.test_colorbar() and returns: unknown