Python Forum
How to prevent tick labels overlapping with axis - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: How to prevent tick labels overlapping with axis (/thread-10092.html)



How to prevent tick labels overlapping with axis - SriRajesh - May-12-2018

I want to see correlation between variables, but when I plot using scatter plot, the variable labels are overlapping with axis, may some one kindly help, how to create space between tick labels and axis

    import pandas as pd
    import numpy as np
    import matplotlib.pyplot as plt
    from scipy import stats
    dataFileName='Input.xlsx'
    sheetName='Data'
    dataRaw=pd.read_excel(dataFileName,sheetname=sheetName)
    noData=len(dataRaw)
    import matplotlib.pylab as plt
    from sklearn.cross_validation import train_test_split
    from sklearn.cross_validation import cross_val_score
    from sklearn.preprocessing import StandardScaler
    import pandas as pd
    import numpy as np

    labels=['GasFlow','Pressureset','Temperature']
    x=dataRaw[labels]
    sm=pd.tools.plotting.scatter_matrix(x,alpha=0.2,figsize=(10,10),c='red',hist_kwds={'color':[burlywood']})
    [s.xaxis.label.set_rotaion(90) for s in sm.reshape(-1)]
    [s.yaxis.label.set_rotaion(0) for s in sm.reshape(-1)]


Here, the y-axis labels are overlapping with axis, 

my input data for first three variables:

My data is below:
GasFlow   Pressureset  Temperature
1.2       1.6          3.2
1.2       1.6          3.2
2.6       1.9          6.5 
1.2       1.6          3.2
2.6       1.9          6.5
1.2       1.6          3.2
1.2       1.6          3.2
2.6       1.9          6.5
1.2       1.6          3.2



RE: How to prevent tick labels overlapping with axis - Larz60+ - May-12-2018

see: https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.tick_params.html
Any of (or combination of) the following:
ax.tick_params(axis='x', which='major', pad=10)
ax.tick_params(axis='y', which='major', pad=10)
ax.tick_params(axis='both', which='major', pad=10)



RE: How to prevent tick labels overlapping with axis - SriRajesh - May-12-2018

It works, but I want to rotate x axis 90 degrees (bottom to top direction) y-axis labels 0 degrees(I want to place them left to right direction). My problem is not xaxis labels are overlap with y axis labels, in fact, due to my variables names are bit longer, and they are extending on to the plot area.