python - Seaborn palettes - prevent recycling of colors -
Seaburns allow defining many colored colored palettes, useful for charts with many rows However, many When setting up the palette with colors, only the first six are used, after which the color is recycled, so it is difficult to separate lines, it can be overridden by calling the pallet clearly, but it is convenient Not Seaburn's Current Pale There is no way to recycle the colors in colors, when more than 6 are defined?
Example: Import Plot as Pipot from Pipot to import matplotlib PDAs as Panda Define a palette with SB # 8 colors as Seaburn cmap = Sb.blend_palette (["firebrick", "palegreen"], 8) sb.palplot (cmap)
set the current palette to; Only 6 colors sb.set_palette (cmap) sb.palplot (sb.color_palette ()) is used
df = pd.DataFrame ({x: [x * 10, x * 10 + 5, x * 10 + 10] in the range for x (8)}) fig, (axis 1, axis 2) = plt.subplots (2,1, fig = (4,6)) using the current palette, repeat the color df. Plot (ax = ax1) ax1.legend (Bbox_to_anchor = (1.2, 1)) using the # palette that defines the current palette, color df.plot (ax = ax2, color = cmap) ax2.legend (bbox_to_anchor = (1.2, 1) does not repeat;
< By using p> code> # palette, by default, only 6 colors meet sb.set_palette (cmap) sb.palplot (sb.color_palette ()) sb.palplot (sb.color_palette (n_colors = 8)) # But the colors The number clearly allows to set it to use all sb.set_palette (equip, n_colors = 8) # However, Only this 6 sb.palplot (sb.color_palette ()) shows sb.palplot (sb.color_palette (n_colors = 8)) unless you explicitly request all colors.)
Comments
Post a Comment