本文整理汇总了Python中matplotlib.font_manager.FontProperties.get_size方法的典型用法代码示例。如果您正苦于以下问题:Python FontProperties.get_size方法的具体用法?Python FontProperties.get_size怎么用?Python FontProperties.get_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.font_manager.FontProperties
的用法示例。
在下文中一共展示了FontProperties.get_size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: slope
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import get_size [as 别名]
#.........这里部分代码省略.........
df = data.copy()
cols = df.columns
df['__label__'] = df.index
df['__order__'] = range(len(df.index))
if kind == 'stack':
f, axarr = plt.subplots(len(df), len(cols) - 1,
facecolor="w",
squeeze=False,
sharex=True) #,sharey=True)
else:
#f, axarr = plt.subplots(2,len(cols)-1,facecolor="w",squeeze=True,figsize=(width,height),dpi=30)#,sharex=True)#,sharey=True)
f = plt.figure(figsize=(width, height), dpi=30, facecolor="w")
gs = gridspec.GridSpec(
nrows=20,
ncols=len(cols) - 1
) # the 20 rows are just there to provide enought space for the title
axarr = []
axarr_X = []
for i in range(len(cols) - 1):
axarr.append(plt.subplot(gs[:19, i]))
axarr_X.append(plt.subplot(gs[19, i]))
axarr = np.array(axarr)
axarr_X = np.array(axarr_X)
renderer = f.canvas.get_renderer()
data_range = [data.min().min(), data.max().max()]
fh = f.get_figheight()
fw = f.get_figwidth()
fdpi = f.get_dpi()
nt = fh // (font.get_size() / 72) / 2
res = np.diff(data_range)[0] / nt * 2
if not hasattr(axarr, 'transpose'):
axarr = [axarr]
for i in range((len(cols) - 1)):
ax = axarr[i]
axarr_X[i].yaxis.set_tick_params(width=0)
axarr_X[i].xaxis.set_tick_params(width=0)
"""
from matplotlib.offsetbox import AnchoredOffsetbox, TextArea, HPacker
# orange label
obox1 = TextArea("orange - ", textprops=dict(color="k", size=15))
obox2 = TextArea("5 ", textprops=dict(color="b", size=15))
obox3 = TextArea(": ", textprops=dict(color="k", size=15))
obox4 = TextArea("10 ", textprops=dict(color="r", size=15))
orangebox = HPacker(children=[obox1, obox2, obox3, obox4],
align="center", pad=0, sep=5)
"""
if kind == 'interval':
labelsL = df.groupby(pd.cut(df[cols[i]], nt))['__label__'].agg(
', '.join).dropna()
labelsR = df.groupby(pd.cut(df[cols[i + 1]], nt))['__label__'].agg(
', '.join).dropna()
yPos_L = df.groupby(pd.cut(df[cols[i]],
nt))[cols[i]].mean().dropna()
yPos_R = df.groupby(pd.cut(df[cols[i + 1]],
nt))[cols[i + 1]].mean().dropna()
示例2: slope
# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import get_size [as 别名]
def slope(data,
kind='interval',
marker='%0.f',
color=None,
title='',
font_family='GillSans',
font_size=12,
width=12,
height=8,
ax=None,
savename=None,
dpi=150,
wspace=None, ):
font = FontProperties(font_family)
font.set_size(font_size)
bx = None
df = data.copy()
cols = df.columns
df['__label__'] = df.index
df['__order__'] = range(len(df.index))
if kind == 'stack':
f, axarr = plt.subplots(len(df), len(cols) - 1,
facecolor="w",
squeeze=False,
sharex=True) #,sharey=True)
else:
f = plt.figure(figsize=(width, height), dpi=30, facecolor="w")
gs = gridspec.GridSpec(
nrows=20,
ncols=len(cols) - 1
) # the 20 rows are just there to provide enought space for the title
axarr = []
axarr_X = []
for i in range(len(cols) - 1):
axarr.append(plt.subplot(gs[:19, i]))
axarr_X.append(plt.subplot(gs[19, i]))
axarr = np.array(axarr)
axarr_X = np.array(axarr_X)
renderer = f.canvas.get_renderer()
data_range = [data.min().min(), data.max().max()]
fh = f.get_figheight()
fw = f.get_figwidth()
fdpi = f.get_dpi()
nt = fh // (font.get_size() / 72) / 2
res = np.diff(data_range)[0] / nt * 2
if not hasattr(axarr, 'transpose'):
axarr = [axarr]
for i in range((len(cols) - 1)):
ax = axarr[i]
axarr_X[i].yaxis.set_tick_params(width=0)
axarr_X[i].xaxis.set_tick_params(width=0)
"""
from matplotlib.offsetbox import AnchoredOffsetbox, TextArea, HPacker
# orange label
obox1 = TextArea("orange - ", textprops=dict(color="k", size=15))
obox2 = TextArea("5 ", textprops=dict(color="b", size=15))
obox3 = TextArea(": ", textprops=dict(color="k", size=15))
obox4 = TextArea("10 ", textprops=dict(color="r", size=15))
orangebox = HPacker(children=[obox1, obox2, obox3, obox4],
align="center", pad=0, sep=5)
"""
if kind == 'interval':
labelsL = df.groupby(pd.cut(df[cols[i]], nt))['__label__'].agg(
', '.join).dropna()
labelsR = df.groupby(pd.cut(df[cols[i + 1]], nt))['__label__'].agg(
', '.join).dropna()
yPos_L = df.groupby(pd.cut(df[cols[i]],
nt))[cols[i]].mean().dropna()
yPos_R = df.groupby(pd.cut(df[cols[i + 1]],
nt))[cols[i + 1]].mean().dropna()
yMark_L = df.groupby(pd.cut(df[cols[i]],
nt))[cols[i]].mean().dropna()
yMark_R = df.groupby(pd.cut(df[cols[i + 1]],
nt))[cols[i + 1]].mean().dropna()
yPos_ = df[[cols[i], cols[i + 1]]]
if kind == 'ordinal':
yPos_L = df[[cols[i]]].rank(ascending=False).applymap(
lambda el: round(el + 0.1))
yPos_R = df[[cols[i + 1]]].rank(ascending=False).applymap(
lambda el: round(el + 0.1))
yMark_L = df.groupby(cols[i])[cols[i]].mean().dropna()
yMark_R = df.groupby(cols[i + 1])[cols[i + 1]].mean().dropna()
yMark_L.sort(ascending=False)
#.........这里部分代码省略.........