Making the labels of the scatterplot vertical and horizontal in Pandas

前端 未结 2 2312
-上瘾入骨i
-上瘾入骨i 2021-02-20 14:36

I\'m using Pandas to draw a scatterplot matrix: from pandas.tools.plotting import scatter_matrix. The problem is that the names of the columns in the <

2条回答
  •  情歌与酒
    2021-02-20 15:06

    scatter_matrix returns a two-dimensional array of matplotlib subplots. This means you should be able to iterate over the two arrays and use matplotlib functions to rotate axes. Based on the source used to implement scatter_matrix and the private helper function _label_axis, it looks as though you should be able to perform your rotations for all the plots with:

    from matplotlib.artist import setp
    
    x_rotation = 90
    y_rotation = 90
    
    for row in axs:
        for subplot in row:
            setp(subplot.get_xticklabels(), rotation=x_rotation)
            setp(subplot.get_yticklabels(), rotation=y_rotation)
    

    I don't have a good way to test this so it may require a bit of playing around.

提交回复
热议问题