from IPython.core.display import display, HTML
display(HTML("<style>.container { width:90% !important; }</style>"))
from matplotlib import rcParams
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt
plt.rcParams['axes.unicode_minus']=False
# Say, "the default sans-serif font is COMIC SANS"
plt.rcParams['font.sans-serif'] = ["Taipei Sans TC Beta"]
# Then, "ALWAYS use sans-serif fonts"
plt.rcParams['font.family'] = "sans-serif"
plt.rcParams.update({'font.size': 22})
plt.xlabel("あそこ") # 步驟三
plt.ylabel("y軸")
plt.title("標題")
plt.show()
another method https://stackoverflow.com/questions/23197124/display-non-ascii-japanese-characters-in-pandas-plot-legend
https://albertauyeung.github.io/2020/03/15/matplotlib-cjk-fonts.html
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.font_manager as font_manager
df = pd.DataFrame( data=np.random.random( (2,2) ), columns=[u'é',u'日本'] )
ax = df.plot()
legend = ax.legend()
font = font_manager.FontProperties(fname='/Users/user/Downloads/IPAfont00303/ipag.ttf')
for text in legend.texts:
text.set_font_properties(font)
plt.show()
pd.set_option('display.max_column',None)
pd.set_option('display.max_rows',None)
pd.set_option('display.max_seq_items',None)
pd.set_option('display.max_colwidth', 500)
pd.set_option('expand_frame_repr', True)
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('retina')
jupyter lab build --name='my_name'
df.plot(figsize=(10,5))