Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Labels
questionFurther information is requested
@adsian

Description

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /