Matplotlib:: Not Showing all x-axis data frame variable

后端 未结 1 1845
太阳男子
太阳男子 2020-12-21 08:18

I have a data frame with head as:

    m_srcaddr       total_fwd_size  total_rev_size
0   10.19.139.141   2479.335    175.000
1   10.19.139.143   888.141 92.4         


        
相关标签:
1条回答
  • 2020-12-21 08:31

    Just change your xticks call to:

    plt.xticks(df.index, df['m_srcaddr'], rotation=90)
    

    The first argument gives the locations to put the ticks (df.index here is equivalent to np.arange(len(df)), but if your index isn't evenly spaced use the arange). The second argument gives the tick labels.


    matplotlib.pyplot.xticks(*args, **kwargs)

    Get or set the x-limits of the current tick locations and labels.

    # return locs, labels where locs is an array of tick locations and
    # labels is an array of tick labels.
    locs, labels = xticks()
    
    # set the locations of the xticks
    xticks( arange(6) )
    
    # set the locations and labels of the xticks
    xticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') )
    

    The keyword args, if any, are Text properties. For example, to rotate long labels:

    xticks( arange(12), calendar.month_name[1:13], rotation=17 )
    
    0 讨论(0)
提交回复
热议问题