bsherin / tactic

5 stars 1 forks source link

replace get_cmap in tiles (doesn't work because of changes to matplotlib in 3.9.0) #1198

Open bsherin opened 6 months ago

bsherin commented 6 months ago

See D3DiscussionHeatmapPortal

bsherin commented 5 months ago

essentially instead of using

cmap=get_cmap(self.color_palette)

I need to have

cmap = matplotlib.colormaps[self.palette_name]

In d3 tiles I'll need to use palette_to_hex. In some tiles this appears as an extra method. But now the D3Tile class has this built in as:

    def palette_to_hex(self, cmap, num):
        step = 1.0 / num
        cmap = mpl.colormaps[self.palette_name]
        breaks = [i * step for i in range(num)]
        return [rgb2hex(cmap(bb)) for bb in breaks]
bsherin commented 5 months ago

Should probably also document how to use palettes.