我不知道是否可以使用Matplotlib或seaborn或其他工具在一个图形中绘制一条直线和一个条形图(烛台样式)。如下图所示(在excel中):
x轴和y轴相同
在下面的响应之后,我选择mplfinance:mplfinance
我有以下数据帧(每日)
def ploting_chart(daily):
# Take marketcolors from 'yahoo'
mc = mpf.make_marketcolors(base_mpf_style='yahoo',up='#ff3300',down='#009900',inherit=True)
# Create a style based on `seaborn` using those market colors:
s = mpf.make_mpf_style(base_mpl_style='seaborn',marketcolors=mc,y_on_right=True,
gridstyle = 'solid' , mavcolors = ['#4d79ff','#d24dff']
)
# **kwargs
kwargs = dict(
type='candle',mav=(7,15),volume=True, figratio=(11,8),figscale=2,
title = 'Covid-19 Madagascar en traitement',ylabel = 'Total en traitement',
update_width_config=dict(candle_linewidth=0.5,candle_width=0.5),
ylabel_lower = 'Total'
)
# Plot my new custom mpf style:
mpf.plot(daily,**kwargs,style=s,scale_width_adjustment=dict(volume=0.4))
我得到了最后的结果
是的,mplfinance允许您在同一绘图或多个子绘图上绘制多个数据集,其中每个数据集可以是烛台、ohlc条形图、直线图、散点图或条形图
有关更多信息,请参见示例:
注意,作为一般规则,建议不要使用“External Axes Method”,如果您试图通过mplfinance在panels模式下完成的任务可以通过其他方式完成
是的,
plt.figure
或plt.subplots
为您提供一个地物对象,然后您可以根据需要绘制任意数量的地物。事实上,如果你使用Seaborn
不支持Candlestick
,但可以使用matplotlib
在同一轴上进行打印您甚至可以使用pandas
df.plot(data,kind='bar',ax=ax,**kwargs)
在同一轴对象内进行打印注意:一些
seaborn
图表不支持在同一个ax
上打印,因为它们使用自己的grid
,例如relplot
相关问题 更多 >
编程相关推荐