0
如何在海宝中的FacetGrid
内定制蜱标签的属性?在下面的例子中我想仅改变x轴ticklabels的字体大小:通过axes
阵列FacetGrid
对象这似乎不必要的复杂的在seaborn中定制facetgrid xticks和标签
import matplotlib.pylab as plt
import seaborn as sns
df1 = pandas.DataFrame({"x": np.random.rand(100),
"y": np.random.rand(100)})
df1["row"] = "A"
df1["col"] = "1"
df2 = pandas.DataFrame({"x": np.random.rand(100),
"y": np.random.rand(100) + 1})
df2["row"] = "A"
df2["col"] = "2"
df = pandas.concat([df1, df2])
g = sns.FacetGrid(df, row="row", col="col", hue="col")
g.map(plt.scatter, "x", "y")
print g.axes
row, col = g.axes.shape
for i in range(row):
for j in range(col):
ax = g.axes[i, j]
print "ax: ", ax.get_xticklabels()
ax.set_xticklabels(ax.get_xticklabels(), fontsize=6)
我的溶液进行迭代。我知道fontscale
可以在全局设置,但我只想更改x轴ticklabel字体。有一个更好的方法吗?还有一种方法可以将标签样式自定义为科学记数法?