jupyter notebook Chinese garbage problem
Installation of fonts
Add the following code before executing the code:
import as plt ['-serif']=['SimHei'] ['axes.unicode_minus']=False
Jupyter Notebook under Mac to draw pictures display Chinese garbled code
For mac (maybe windows too)
Tried a lot of ways ~ write this article for everyone to avoid the mine! Those who let you go to download and modify the configuration file and so on ~ all to the side, are copied and copied ~ nothing nutritious, a super waste of time and a huge hassle!
(It didn't work for me.)
Step 1 Check which Chinese fonts are in your own fonts
import matplotlib a=sorted([ for f in matplotlib.font_manager.]) for i in a: print(i)
The result is partly as follows: Find Chinese fonts from it: mine is still bold Heiti TC.
Looks like we still have macs that support Chinese.
It's just that the name is in Chinese, so why don't people recognize it?
Step 2 Select the corresponding heiti TC to be displayed.
['-serif']='Heiti TC' ['axes.unicode_minus'] = False # Negative sign is displayed normally
That's it!
An example 🌰 is as follows
I'm a little 🌰:
['-serif']='Heiti TC' ['axes.unicode_minus'] = False # The negative sign is displayed normally # Set the line width (figsize=(8,5)) (attr, v1, linewidth = 4) # Set icon titles and add labels to axes ("Trends in Daily Hits", fontsize=20) ('',fontsize=10) ('',fontsize=10)
summarize
Above! For personal experience, I hope it can give you a reference, and I hope you can support me more.