How To Plot Multiple Histograms On Same Plot With Seaborn

后端 未结 1 1236
伪装坚强ぢ
伪装坚强ぢ 2020-12-28 14:07

With matplotlib, I can make a histogram with two datasets on one plot (one next to the other, not overlay).

import matplotlib.pyplot as plt
import random

x          


        
相关标签:
1条回答
  • 2020-12-28 14:18

    If I understand you correctly you may want to try something this:

    fig, ax = plt.subplots()
    for a in [x, y]:
        sns.distplot(a, bins=range(1, 110, 10), ax=ax, kde=False)
    ax.set_xlim([0, 100])
    

    Which should yield a plot like this:

    UPDATE:

    Looks like you want 'seaborn look' rather than seaborn plotting functionality. For this you only need to:

    import seaborn as sns
    plt.hist([x, y], color=['r','b'], alpha=0.5)
    

    Which will produce:

    0 讨论(0)
提交回复
热议问题