"Matplotlib,seaborn"의 두 판 사이의 차이
ph
(새 문서: == xticks on top == ref. https://matplotlib.org/3.1.3/gallery/ticks_and_spines/tick_xlabel_top.html <source> import matplotlib.pyplot as plt import numpy as np plt.rcParams['xtick.b...) |
잔글 |
||
| 8번째 줄: | 8번째 줄: | ||
plt.rcParams['xtick.bottom'] = plt.rcParams['xtick.labelbottom'] = False | plt.rcParams['xtick.bottom'] = plt.rcParams['xtick.labelbottom'] = False | ||
plt.rcParams['xtick.top'] = plt.rcParams['xtick.labeltop'] = True | plt.rcParams['xtick.top'] = plt.rcParams['xtick.labeltop'] = True | ||
| + | </source> | ||
| + | |||
| + | == use of ttf with seaborn == | ||
| + | ref. https://matplotlib.org/gallery/api/font_file.html | ||
| + | <source> | ||
| + | import os | ||
| + | from matplotlib import font_manager as fm, rcParams | ||
| + | import matplotlib.pyplot as plt | ||
| + | |||
| + | fig, ax = plt.subplots() | ||
| + | |||
| + | fpath = os.path.join(rcParams["datapath"], "fonts/ttf/cmr10.ttf") | ||
| + | prop = fm.FontProperties(fname=fpath) | ||
| + | </source> | ||
| + | <source> | ||
| + | p = sns.lineplot(ax=ax, data=data, palette='tab10', linewidth=1, dashes=dash_styles) | ||
| + | plt.setp(p.get_xticklabels(), rotation=90, fontproperties=prop) | ||
</source> | </source> | ||
2020년 2월 28일 (금) 18:40 판
xticks on top
ref. https://matplotlib.org/3.1.3/gallery/ticks_and_spines/tick_xlabel_top.html
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['xtick.bottom'] = plt.rcParams['xtick.labelbottom'] = False
plt.rcParams['xtick.top'] = plt.rcParams['xtick.labeltop'] = Trueuse of ttf with seaborn
ref. https://matplotlib.org/gallery/api/font_file.html
import os
from matplotlib import font_manager as fm, rcParams
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
fpath = os.path.join(rcParams["datapath"], "fonts/ttf/cmr10.ttf")
prop = fm.FontProperties(fname=fpath)p = sns.lineplot(ax=ax, data=data, palette='tab10', linewidth=1, dashes=dash_styles)
plt.setp(p.get_xticklabels(), rotation=90, fontproperties=prop)