如何跳过财务Matplotlib Python图表中的空日期(周末)? [英] How to skip empty dates (weekends) in a financial Matplotlib Python graph?
问题描述
ax.plot_date((dates, dates), (highs, lows), '-')
我目前使用这个命令绘制财经高点和低点,使用 Matplotlib 的。它的工作原理非常好,但是我怎样才能在没有市场数据的情况下(例如周末和假日)去除x轴左侧的空白空间?
I'm currently using this command to plot financial highs and lows using Matplotlib. It works great, but how do I remove the blank spaces in the x-axis left by days without market data, such as weekends and holidays?
我有日期列表,高点,低点,关闭并打开。我无法找到任何创建带有x轴的图表来显示日期但不强制执行恒定比例的示例。
I have lists of dates, highs, lows, closes and opens. I can't find any examples of creating a graph with an x-axis that show dates but doesn't enforce a constant scale.
推荐答案
我认为您需要使用 xticks人工合成您想要的剧情的确切形式
将刻度标签设置为代表日期的字符串(当然,即使您表示的日期不是等间隔,也会以等间隔放置刻度),然后使用普通的 > plot
。
I think you need to "artificially synthesize" the exact form of plot you want by using xticks
to set the tick labels to the strings representing the dates (of course placing the ticks at equispaced intervals even though the dates you're representing aren't equispaced) and then using a plain plot
.
这篇关于如何跳过财务Matplotlib Python图表中的空日期(周末)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!