设置具有 2 个不同值范围的 Seaborn PairGrid x 轴
Set Seaborn PairGrid x-axis with 2 different value ranges
[分辨率如下所述。]
我正在尝试创建一个 PairGrid。 X 轴至少有 2 个不同的值范围,尽管即使下面的 'cvar' 是自己绘制的,x 轴也会覆盖自己。
我的问题:有没有办法将 x 轴标签倾斜为垂直或减少 x 轴标签以使其不重叠?还有其他方法可以解决这个问题吗?
====================
import seaborn as sns
import matplotlib.pylab as plt
import pandas as pd
import numpy as np
columns = ['avar', 'bvar', 'cvar']
index = np.arange(10)
df = pd.DataFrame(columns=columns, index = index)
myarray = np.random.random((10, 3))
for val, item in enumerate(myarray):
df.ix[val] = item
df['cvar'] = [400,450,43567,23000,19030,35607,38900,30202,24332,22322]
fig1 = sns.PairGrid(df, y_vars=['avar'],
x_vars=['bvar', 'cvar'],
palette="GnBu_d")
fig1.map(plt.scatter, s=40, edgecolor="white")
# The fix: Add the following to rotate the x axis.
plt.xticks( rotation= -45 )
=====================
上面的代码生成了这张图片
谢谢!
我终于明白了。我在上面的原始代码中添加了 "plt.xticks( rotation= -45 )" 。可以在 MatPlotLib 网站 here 上获得更多资金。
[分辨率如下所述。]
我正在尝试创建一个 PairGrid。 X 轴至少有 2 个不同的值范围,尽管即使下面的 'cvar' 是自己绘制的,x 轴也会覆盖自己。
我的问题:有没有办法将 x 轴标签倾斜为垂直或减少 x 轴标签以使其不重叠?还有其他方法可以解决这个问题吗?
====================
import seaborn as sns
import matplotlib.pylab as plt
import pandas as pd
import numpy as np
columns = ['avar', 'bvar', 'cvar']
index = np.arange(10)
df = pd.DataFrame(columns=columns, index = index)
myarray = np.random.random((10, 3))
for val, item in enumerate(myarray):
df.ix[val] = item
df['cvar'] = [400,450,43567,23000,19030,35607,38900,30202,24332,22322]
fig1 = sns.PairGrid(df, y_vars=['avar'],
x_vars=['bvar', 'cvar'],
palette="GnBu_d")
fig1.map(plt.scatter, s=40, edgecolor="white")
# The fix: Add the following to rotate the x axis.
plt.xticks( rotation= -45 )
=====================
上面的代码生成了这张图片
谢谢!
我终于明白了。我在上面的原始代码中添加了 "plt.xticks( rotation= -45 )" 。可以在 MatPlotLib 网站 here 上获得更多资金。