如何在matplotlib图上更改所有元素(刻度,标签,标题)的字体大小?
我知道如何更改刻度标签尺寸,这是通过以下方式完成的:
import matplotlib
matplotlib.rc('xtick', labelsize=20)
matplotlib.rc('ytick', labelsize=20)
Run Code Online (Sandbox Code Playgroud)
但是如何改变其余部分呢?
我的seaborn情节有一个很大的问题.由于某种原因,沿轴的数字打印的字体非常小,这使得它们不可读.我试着用它来扩展它们
with plt.rc_context(dict(sns.axes_style("whitegrid"),
**sns.plotting_context(font_scale=5))):
b = sns.violinplot(y="Draughts", data=dr)
Run Code Online (Sandbox Code Playgroud)
在seaborn中,如何更改x和y轴标签字体大小?而不是使用"设置上下文"方法,有没有办法专门更改轴标签?这是我的代码:
def corrfunc(x, y, **kws):
r = stats.pearsonr(x, y)[0] ** 2
ax = plt.gca()
ax.annotate("r$^2$ = {:.2f}".format(r),
xy=(.1, .9), xycoords=ax.transAxes, fontsize=16)
if r > 0.6:
col = 'g'
elif r < 0.6:
col = 'r'
sns.regplot(x, y, color=col)
return r
IC_Plot = sns.PairGrid(df_IC, palette=["red"])
IC_Plot.map_offdiag(corrfunc)
IC_Plot.savefig("Save_Pair.png")
Run Code Online (Sandbox Code Playgroud) 这个问题的说明不适用于 Seaborn FacetPlots。是否有可能获得同样的方法?
我一直在寻找 SO 以增加 relplot 中的图例/色调大小。
plt.rcParams["axes.labelsize"] = 20
g = sns.relplot(x='Time(days)', y='Duration Total (s)', hue='Outcome', data=t1,height=15, aspect=1, s=50);
plt.suptitle("a_10",fontsize=25, fontweight='bold')
Run Code Online (Sandbox Code Playgroud)
我似乎无法绕过它。有这么多混合引用,这有点令人困惑。
注意:这是与“ 如何使用seaborn FacetGrid更改字体大小? ” 不同的问题。在构面网格内使用热图时,此处建议的方法不起作用。
在构面网格内绘制热图时,如何更改构面标题的字体大小?
尝试下面的代码两种方法,传递fontsize=到set_titles()并在绘图背景下包裹了整个事情。据我所知,尽管字体重量确实发生了变化,但在使用热图时,似乎都没有影响面标题。使用热图时,是否还有其他选项可以控制构面标题?
import pandas as pd
import numpy as np
import itertools
import seaborn as sns
print("seaborn version {}".format(sns.__version__))
# R expand.grid() function in Python
# /sf/answers/849196981/
def expandgrid(*itrs):
product = list(itertools.product(*itrs))
return {'Var{}'.format(i+1):[x[i] for x in product] for i in range(len(itrs))}
methods=['method 1', 'method2', 'method 3', 'method 4']
times = range(0,100,10)
data = pd.DataFrame(expandgrid(methods, times, times))
data.columns = ['method', 'dtsi','rtsi']
data['nw_score'] = np.random.sample(data.shape[0])
def facet(data,color):
data = data.pivot(index="dtsi", columns='rtsi', values='nw_score') …Run Code Online (Sandbox Code Playgroud)