Python Forum
How to prevent tick labels overlapping with axis
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to prevent tick labels overlapping with axis
#1
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
Reply
#2
see: https://matplotlib.org/api/_as_gen/matpl...arams.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)
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Dataframe.hist() labels overlapping graphs RawlinsCross 2 4,561 Jan-14-2020, 03:02 PM
Last Post: RawlinsCross
  How matplotlib automatically set x-axis and y-axis limits for bar graph ? ift38375 3 5,541 Jul-04-2019, 08:23 AM
Last Post: scidam
  Add tick labels in healpy.mollview ? BourbonKid67 4 4,859 Apr-10-2019, 10:19 AM
Last Post: BourbonKid67

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020