[Python] Give each hvplot box plot a different colour from default colour cycle

Discussão em 'Python' iniciado por Stack, Março 7, 2025.

  1. Stack

    Stack Membro Participativo

    I have a simple hvplot example where I want to demonstrate 3 charts side by side (line plot, histogram & box plot). Is there an easy way to give each box plot a colour matching the other charts (i.e. from the default colour cycle)?

    import pandas as pd
    import hvplot.pandas

    data = pd.read_csv('https://raw.githubusercontent.com/ChrisWalshaw/DataViz/master/Data/Products/DailySales.csv', index_col=0)
    data.index = pd.to_datetime(data.index)
    print(data.head())

    selected = ['A', 'F', 'L']

    plot1 = data[selected].hvplot.line(
    frame_height=300, frame_width=300,
    )
    plot2 = data[selected].hvplot.hist(
    frame_height=300, frame_width=300,
    )
    plot3 = data[selected].hvplot.box(
    frame_height=300, frame_width=300,
    )
    plot = plot1 + plot2 + plot3
    hvplot.show(plot)


    [​IMG]

    Continue reading...

Compartilhe esta Página