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)

 6 palette palette

  set the current palette to; Only 6 colors sb.set_palette (cmap) sb.palplot (sb.color_palette ()) is used   

 palette

  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;   

chart with 6 or 8 colors

 

< 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.)

Enter image details here  Enter image details here  Enter image details here Now all 8 numbers in the image insert chart, axis 1 = plt.subplots (1,1, fig = (4,3)) Used for DF. Plot (axis = axis 1) ax1.legend (bbox_to_anchor = (1.2, 1)); </ Code> </ pre> <p> <img src =

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -