Skip to content

Instantly share code, notes, and snippets.

@sagorbrur
Created October 29, 2021 10:08
Show Gist options
  • Save sagorbrur/99881b214ddef705de570357a7806447 to your computer and use it in GitHub Desktop.
Save sagorbrur/99881b214ddef705de570357a7806447 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
from matplotlib import font_manager
import seaborn as sns
font_path = './font/IPAGothic_24302.ttf' # Your font path goes here, as example using jp fonts
font_manager.fontManager.addfont(font_path)
prop = font_manager.FontProperties(fname=font_path)
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = prop.get_name()
# test
data = [('上海', 285), ('杭州', 225), ('北京', 163), ('广州', 136)]
sns.barplot(x=[k for k, _ in data], y=[v for _, v in data])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment