Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing from current font. FigureCanvasAgg.draw(self) #677

Open
adsian opened this issue Jul 25, 2024 · 0 comments
Open

missing from current font. FigureCanvasAgg.draw(self) #677

adsian opened this issue Jul 25, 2024 · 0 comments
Labels
question Further information is requested

Comments

@adsian
Copy link

adsian commented Jul 25, 2024

Ask anything you want about mplfinance usage, project philosophy and/or priorities, or anything else related to mplfinance.

import mplfinance as mpf
import pandas as pd
import matplotlib.pyplot as plt

# 设置 matplotlib 的默认字体为 SimHei
plt.rcParams['font.family'] = 'SimHei'

# 假设您有以下 DataFrame 形式的数据
df = pd.DataFrame({
    'Date': ['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-04', '2023-01-05', '2023-01-06', '2023-01-07'],
    'Open': [100, 102, 98, 101, 99, 103, 104],
    'High': [101, 104, 100, 102, 101, 105, 106],
    'Low': [99, 100, 97, 99, 97, 101, 102],
    'Close': [100, 101, 99, 100, 100, 103, 104]
})

# 将日期列转换为 datetime 格式并设置为索引
df['Date'] = pd.to_datetime(df['Date'])
df.set_index('Date', inplace=True)

# 绘制 K 线图
mpf.plot(df, type='candle', figsize=(12, 6), title='K 线图')

error:

/Users/roger/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pycharm_matplotlib_backend/backend_interagg.py:80: UserWarning: Glyph 32447 (\N{CJK UNIFIED IDEOGRAPH-7EBF}) missing from current font.
FigureCanvasAgg.draw(self)
/Users/roger/Applications/PyCharm Professional Edition.app/Contents/plugins/python/helpers/pycharm_matplotlib_backend/backend_interagg.py:80: UserWarning: Glyph 22270 (\N{CJK UNIFIED IDEOGRAPH-56FE}) missing from current font.
FigureCanvasAgg.draw(self)

question:

how can I generate pics with chinese characters with local font settings? (ignore environments)

@adsian adsian added the question Further information is requested label Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant