-2

For Pandas.DataFrame plot() fn, the 'rot' keyword argument rotates the x-axis ticks specifically. So how does one rotate the y-axis ticks? There's some documentation here, which gives the anticipated syntax for the 'rot' argument for either xticks or yticks, but lacking of an example.

2 Answers2

0

If you want to rotate axes ticks, it's convenient to use matplotlib feature. After importing matplotlib as 'plt', you just have to write:

plt.xticks(rotation=specify_here_a_value)
plt.yticks(rotation=specify_here_a_value)
plt.show()

It will do the work for you. Coming to the question you asked, 'rot' keyword takes argument or rotates the axis based on the type of graph as said in the documentation:

rot : int, default None

Rotation for ticks (xticks for vertical, yticks for horizontal plots)

I think if plot is vertical, it rotates xticks and if it is horizontal it rotates yticks.

Matplotlib provides the better way as written above. I find it much more effective.

Arnav
  • 163
  • 1
  • 8
0

Example

axs= pd.plotting.scatter_matrix(numericData, figsize = (colNo,colNo))
    
    for i in range(colNo):
        vert = axs[i,0]
        vert.yaxis.label.set_rotation(0)
        vert.xaxis.label.set_ha('right')
        vert.set_yticks(())
        h = axs[colNo-1, i]
        h.xaxis.label.set_rotation(90)
        h.set_xticks(())