From 3efefcb1fce63d0aba7b203c595976a94ffa8a44 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Sat, 20 Apr 2024 21:56:16 +0800 Subject: [PATCH] =?UTF-8?q?indicator=20=E7=BB=98=E5=88=B6=E6=97=B6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=20x=20=E8=BD=B4=E4=B8=BA=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hikyuu/draw/drawplot/matplotlib_draw.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hikyuu/draw/drawplot/matplotlib_draw.py b/hikyuu/draw/drawplot/matplotlib_draw.py index 0993ad77..cd7a747e 100644 --- a/hikyuu/draw/drawplot/matplotlib_draw.py +++ b/hikyuu/draw/drawplot/matplotlib_draw.py @@ -147,7 +147,7 @@ class StockFuncFormatter(object): def getDayLocatorAndFormatter(dates): """获取显示日线时使用的Major Locator和Major Formatter""" - sep = len(dates) / 8 + sep = len(dates) / 10 loc = [ (i, str(d) if (i != (len(dates) - 1)) and (i % sep != 0) else "{}-{}-{}".format(d.year, d.month, d.day)) for i, d in enumerate(dates) @@ -394,6 +394,10 @@ def iplot( axes.set_xlim(-1, len(indicator) + 1) if kref: ax_set_locator_formatter(axes, kref.get_datetime_list(), kref.get_query().ktype) + else: + k = indicator.get_context() + if len(k) > 0: + ax_set_locator_formatter(axes, k.get_datetime_list(), k.get_query().ktype) # draw() @@ -474,6 +478,10 @@ def ibar( axes.set_xlim(-1, len(indicator) + 1) if kref: ax_set_locator_formatter(axes, kref.get_datetime_list(), kref.get_query().ktype) + else: + k = indicator.get_context() + if len(k) > 0: + ax_set_locator_formatter(axes, k.get_datetime_list(), k.get_query().ktype) # draw()