matplotlib scatterplot x axis labels

后端 未结 2 1045
旧时难觅i
旧时难觅i 2020-12-06 05:49

When I\'m adding the c option to a scatterplot in matplotlib, the x axis labels dissapear. Here\'s an example: https://github.com/Kornel/scatterplot-matplotlib/blob/master/S

2条回答
  •  一向
    一向 (楼主)
    2020-12-06 06:03

    That looks like a strange bug with pandas plotting to me! Here's a way around it:

    fig, ax = plt.subplots()
    df.plot(kind='scatter',x='X', y='Y', c='C', ax=ax)
    ax.set_xlabel("X")
    plt.show()
    

    This will give you the graph you expect:

提交回复
热议问题