[Python] Pandas boxplots - styling props with colors not working

Discussão em 'Python' iniciado por Stack, Setembro 29, 2024.

  1. Stack

    Stack Membro Participativo

    I would like to style all aspects of my boxplots via style sheets and apply the defined styles via plt.style.use("my_style"). So the goal is to "out source" all the styling attributes of the chart via code and define them inside the style.

    Unfortunately not all colors are recognized. [​IMG]

    This is just an excerpt from the file:

    ### BoxPLots

    boxplot.showmeans: True
    boxplot.showcaps: True
    boxplot.showbox: True
    boxplot.showfliers: True
    boxplot.meanline: True
    boxplot.showmeans: True
    boxplot.showcaps: True
    boxplot.showbox: True
    boxplot.showfliers: True
    boxplot.meanline: True

    # these color styles are parially applied
    boxplot.medianprops.color: "red". # not applied
    boxplot.medianprops.linestyle: solid. # applied
    boxplot.meanprops.color: "yellow" # applied
    boxplot.meanprops.linestyle: dashed. # applied
    boxplot.boxprops.color: 'red' # not applied
    boxplot.boxprops.linestyle: dotted # applied


    its getting applied by:

    df = pd.DataFrame(array, columns=['Values'])
    plt.style.use("my_style")
    bp = df.boxplot(column=['Values'],
    capprops=dict(color='#ff5c00'),
    flierprops=dict(marker='o', markeredgecolor='#fdfc60', markersize=10))


    Result: The meanline is shown and its color, as well as all linestyles are applied but neither the colors for the box nor the median.

    The programmatically definitions like for capprops and flierprops are working.

    Continue reading...

Compartilhe esta Página