python - 如何更改 mplfinance 标题中的字体大小和字体类型
问题描述
我有以下代码:
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
?
解决方案
- 根据如何使用新的 mplfinance 包编辑无花果,
returnfig=True
用于提取对象fig
列表。axes
- 然后使用标准
matplotlib
方法添加 anaxes title
和 afigure suptitle
,因为title
inmpf.plot
实际上是figure suptitle
,而不是axes title
。 - 参考:
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')
推荐阅读
- r - 将多个分组索引合并为一个
- azure - Cosmos DB - Microsoft.Azure.Documents.AddressResolver.EnsureRoutingMapPresent
- kubernetes - 当使用带有路径重定向的 nginx kubernetes 路由 LoadBalancer 时,为什么我无法正确访问我的服务?
- azure-logic-apps - 获取 Azure 逻辑应用表达式中的最大时间戳
- sql - PL/SQL:什么是错误:ORA-04082:表级触发器中不允许新或旧引用
- javascript - 将给定的字符串分成相等的部分,其中子字符串的数量将具有相同的大小和动态性质?
- mysql - 谁能帮我解决这个 SQL 函数中的错误
- javascript - ASP.NET 在 jQuery Bundle 上接收 NullReferenceException
- loadrunner - LoadRunner Controller:需要拆分参数文件
- react-native - 试图在反应原生中合并 3*3 图像网格的 4 个表格单元格