Python Matplotlib Boxplot Color

后端 未结 4 2000
我在风中等你
我在风中等你 2020-12-02 23:34

I am trying to make two sets of box plots using Matplotlib. I want each set of box plot filled (and points and whiskers) in a different color. So basically there will be two

4条回答
  •  猫巷女王i
    2020-12-03 00:10

    Change the color of a boxplot

    import numpy as np 
    import matplotlib.pyplot as plt
    
    #generate some random data
    data = np.random.randn(200)
    d= [data, data]
    #plot
    box = plt.boxplot(d, showfliers=False)
    # change the color of its elements
    for _, line_list in box.items():
        for line in line_list:
            line.set_color('r')
    
    plt.show()
    

提交回复
热议问题