sorting labels in matplotlib scaterplot

后端 未结 3 1918
借酒劲吻你
借酒劲吻你 2021-01-27 02:32

I have the following code for a scatterplot, and the corresponding plot is shown below:

x = [\'C9-U2\', \'C10-U5\', \'C10-U5\', \'C11-U1\', \'C11-U1\']
y = [\'J\         


        
3条回答
  •  生来不讨喜
    2021-01-27 02:51

    Following 'ImportanceOfBeingErnest ', the code could be shorten to

    # initial plot to set sorted axis label
    us = plt.plot(sorted(x),sorted(y))
    [u.remove() for u in us]
    
    # now plot the real thing, sorting not required
    plt.scatter(x,y)
    

提交回复
热议问题