Hierarchical 2D Qualitative Color Palette

I am trying to color different areas in a diagram and need groups of related colors.

Similar to the tab20b and tab20c colormaps, but with up to 7 colors for each group instead of only 4.

Each group of colors should be perceived as related, while they should also be as different from each other as feasible. The individual groups should be as distinct as possible.

I need about 5 groups, and for each group I need versions with 1-7 individual elements.
Both groups and group elements are sets without any order, I would prefer colors that are not perceived as sequential, unlike the sub-colors in tab20b,c.

One simple idea would be to pick one of the qualitative Matplotlib palettes and then use colorsys to create darkened versions of the colors, as described here

This approach doesn’t work well for my application, because:

  1. 7 colors won’t be distinguishable by lightness alone
  2. The colors look sequential (which is more of a cosmetic issue)
  3. When differently colored areas overlap, they are hard to distinguish (e.g. light blue not visible on dark blue).

If I group the tab20 colors, e.g. the brown and the orange colors, the differences in the group are a bit too large.

A better solution is the color generator at Random Color Generator - Colordesigner , but the individual palettes still share colors, e.g. a set of random blue colors also has purples. I’d still have to pick through the colors manually.

Is there any generator available that can automate the creation n groups of m colors that are distinct and blend well?