【问题标题】:How to change font size and font type in mplfinance title如何更改 mplfinance 标题中的字体大小和字体类型
【发布时间】:2021-09-16 14:54:54
【问题描述】:

我有以下代码:

from pandas_datareader import data as web
df = web.DataReader('goog','yahoo', start="2021-07-3", end="2021-09-12")
mpf.plot(df, style='charles', type = 'candle', volume=True, figratio=(12,8), title = "new title \n another title")

您能否告诉我如何更改换行符another title 的字体和大小?

【问题讨论】:

    标签: python python-3.x matplotlib title mplfinance


    【解决方案1】:
    df = web.DataReader('goog','yahoo', start="2021-07-3", end="2021-09-12")
    fig, axlist = mpf.plot(df, style='charles', type = 'candle', volume=True, figratio=(12,8), returnfig=True)
    
    # add a new suptitle
    fig.suptitle('Figure Title', y=1.05, fontsize=30, x=0.59)
    
    # add a title the the correct axes
    axlist[0].set_title('Axis Title', fontsize=25, style='italic', fontfamily='fantasy', loc='center')
    
    # save the figure
    fig.savefig('test.jpg', bbox_inches='tight')
    

    【讨论】:

    • 感谢您的帮助。
    • @Slartibartfast 不客气。很高兴这对你有用。
    • 您能再回答 1 个问题吗?如果我想抑制在 spyder/jupyter 中绘制的情节并且只是被保存,我该怎么做。原因是RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (matplotlib.pyplot.figure) are retained until explicitly closed and may consume too much memory.
    • 保存后试试fig.clf()
    猜你喜欢
    • 2012-07-22
    • 2011-08-26
    • 2017-12-23
    • 2020-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-05
    相关资源
    最近更新 更多