hikyuu 2.2.3__py3-none-win_amd64.whl → 2.3.0__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hikyuu/cpp/boost_date_time-mt.dll +0 -0
- hikyuu/cpp/boost_serialization-mt.dll +0 -0
- hikyuu/cpp/boost_wserialization-mt.dll +0 -0
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core38.pyd +0 -0
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/data/mysql_upgrade/0024.sql +2 -0
- hikyuu/draw/__init__.py +12 -6
- hikyuu/draw/drawplot/__init__.py +7 -1
- hikyuu/draw/drawplot/icon/1.png +0 -0
- hikyuu/draw/drawplot/icon/10.png +0 -0
- hikyuu/draw/drawplot/icon/11.png +0 -0
- hikyuu/draw/drawplot/icon/12.png +0 -0
- hikyuu/draw/drawplot/icon/13.png +0 -0
- hikyuu/draw/drawplot/icon/14.png +0 -0
- hikyuu/draw/drawplot/icon/15.png +0 -0
- hikyuu/draw/drawplot/icon/16.png +0 -0
- hikyuu/draw/drawplot/icon/17.png +0 -0
- hikyuu/draw/drawplot/icon/18.png +0 -0
- hikyuu/draw/drawplot/icon/19.png +0 -0
- hikyuu/draw/drawplot/icon/2.png +0 -0
- hikyuu/draw/drawplot/icon/20.png +0 -0
- hikyuu/draw/drawplot/icon/21.png +0 -0
- hikyuu/draw/drawplot/icon/22.png +0 -0
- hikyuu/draw/drawplot/icon/23.png +0 -0
- hikyuu/draw/drawplot/icon/24.png +0 -0
- hikyuu/draw/drawplot/icon/25.png +0 -0
- hikyuu/draw/drawplot/icon/26.png +0 -0
- hikyuu/draw/drawplot/icon/27.png +0 -0
- hikyuu/draw/drawplot/icon/28.png +0 -0
- hikyuu/draw/drawplot/icon/29.png +0 -0
- hikyuu/draw/drawplot/icon/3.png +0 -0
- hikyuu/draw/drawplot/icon/30.png +0 -0
- hikyuu/draw/drawplot/icon/31.png +0 -0
- hikyuu/draw/drawplot/icon/32.png +0 -0
- hikyuu/draw/drawplot/icon/33.png +0 -0
- hikyuu/draw/drawplot/icon/34.png +0 -0
- hikyuu/draw/drawplot/icon/35.png +0 -0
- hikyuu/draw/drawplot/icon/36.png +0 -0
- hikyuu/draw/drawplot/icon/37.png +0 -0
- hikyuu/draw/drawplot/icon/38.png +0 -0
- hikyuu/draw/drawplot/icon/39.png +0 -0
- hikyuu/draw/drawplot/icon/4.png +0 -0
- hikyuu/draw/drawplot/icon/40.png +0 -0
- hikyuu/draw/drawplot/icon/41.png +0 -0
- hikyuu/draw/drawplot/icon/42.png +0 -0
- hikyuu/draw/drawplot/icon/43.png +0 -0
- hikyuu/draw/drawplot/icon/44.png +0 -0
- hikyuu/draw/drawplot/icon/45.png +0 -0
- hikyuu/draw/drawplot/icon/46.png +0 -0
- hikyuu/draw/drawplot/icon/47.png +0 -0
- hikyuu/draw/drawplot/icon/48.png +0 -0
- hikyuu/draw/drawplot/icon/49.png +0 -0
- hikyuu/draw/drawplot/icon/5.png +0 -0
- hikyuu/draw/drawplot/icon/6.png +0 -0
- hikyuu/draw/drawplot/icon/7.png +0 -0
- hikyuu/draw/drawplot/icon/8.png +0 -0
- hikyuu/draw/drawplot/icon/9.png +0 -0
- hikyuu/draw/drawplot/icon/__init__.py +0 -0
- hikyuu/draw/drawplot/matplotlib_draw.py +553 -4
- hikyuu/examples/notebook/Demo/Demo1.ipynb +85 -84
- hikyuu/gui/HikyuuTDX.py +19 -16
- hikyuu/gui/data/MainWindow.py +14 -11
- hikyuu/gui/hikyuu_small.png +0 -0
- hikyuu/hub.py +4 -4
- hikyuu/include/hikyuu/DataType.h +3 -1
- hikyuu/include/hikyuu/StockManager.h +10 -0
- hikyuu/include/hikyuu/config.h +3 -0
- hikyuu/include/hikyuu/data_driver/BlockInfoDriver.h +15 -1
- hikyuu/include/hikyuu/data_driver/block_info/mysql/MySQLBlockInfoDriver.h +8 -1
- hikyuu/include/hikyuu/data_driver/block_info/qianlong/QLBlockInfoDriver.h +3 -1
- hikyuu/include/hikyuu/data_driver/block_info/sqlite/SQLiteBlockInfoDriver.h +8 -1
- hikyuu/include/hikyuu/indicator/Indicator.h +4 -4
- hikyuu/include/hikyuu/indicator/IndicatorImp.h +11 -8
- hikyuu/include/hikyuu/indicator/build_in.h +3 -0
- hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +30 -0
- hikyuu/include/hikyuu/indicator/crt/CORR.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/ISLASTBAR.h +30 -0
- hikyuu/include/hikyuu/indicator/crt/SPEARMAN.h +2 -2
- hikyuu/include/hikyuu/indicator/crt/WMA.h +46 -0
- hikyuu/include/hikyuu/indicator/imp/IContext.h +44 -0
- hikyuu/include/hikyuu/indicator/imp/ICorr.h +0 -1
- hikyuu/include/hikyuu/indicator/imp/IIsLastBar.h +27 -0
- hikyuu/include/hikyuu/indicator/imp/ISpearman.h +0 -1
- hikyuu/include/hikyuu/indicator/imp/IWma.h +30 -0
- hikyuu/include/hikyuu/indicator_talib/__init__.py +1 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaAdosc.h +26 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaApo.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaBbands.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaMa.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaMacd.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaMacdext.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaMama.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaMavp.h +41 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaPpo.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaSar.h +26 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaSarext.h +31 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaStddev.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaStoch.h +27 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaStochf.h +26 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaStochrsi.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaT3.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaUltosc.h +26 -0
- hikyuu/include/hikyuu/indicator_talib/imp/TaVar.h +24 -0
- hikyuu/include/hikyuu/indicator_talib/imp/__init__.py +1 -0
- hikyuu/include/hikyuu/indicator_talib/imp/ta_defines.h +288 -0
- hikyuu/include/hikyuu/indicator_talib/imp/ta_imp.h +1364 -0
- hikyuu/include/hikyuu/indicator_talib/ta_crt.h +320 -0
- hikyuu/include/hikyuu/trade_manage/OrderBrokerBase.h +25 -0
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +0 -4
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/PerformanceOptimalSelector.h +1 -1
- hikyuu/include/hikyuu/utilities/Null.h +33 -0
- hikyuu/include/hikyuu/utilities/Parameter.h +9 -9
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +1 -0
- hikyuu/include/hikyuu/version.h +5 -5
- hikyuu/indicator/talib_wrap.py +424 -415
- hikyuu/test/Datetime.py +12 -12
- hikyuu/test/Indicator.py +36 -36
- hikyuu/test/KData.py +11 -11
- hikyuu/test/Stock.py +10 -10
- {hikyuu-2.2.3.dist-info → hikyuu-2.3.0.dist-info}/METADATA +26 -3
- {hikyuu-2.2.3.dist-info → hikyuu-2.3.0.dist-info}/RECORD +131 -52
- {hikyuu-2.2.3.dist-info → hikyuu-2.3.0.dist-info}/top_level.txt +3 -0
- hikyuu/sqlite3.dll +0 -0
- hikyuu/vcruntime140.dll +0 -0
- hikyuu/vcruntime140_1.dll +0 -0
- {hikyuu-2.2.3.dist-info → hikyuu-2.3.0.dist-info}/LICENSE +0 -0
- {hikyuu-2.2.3.dist-info → hikyuu-2.3.0.dist-info}/WHEEL +0 -0
- {hikyuu-2.2.3.dist-info → hikyuu-2.3.0.dist-info}/entry_points.txt +0 -0
|
@@ -4,30 +4,43 @@
|
|
|
4
4
|
交互模式下绘制相关图形,如K线图,美式K线图
|
|
5
5
|
"""
|
|
6
6
|
import sys
|
|
7
|
+
import os
|
|
7
8
|
import datetime
|
|
8
9
|
import logging
|
|
9
10
|
import numpy as np
|
|
10
11
|
import matplotlib
|
|
11
|
-
|
|
12
|
+
import math
|
|
13
|
+
from typing import Union
|
|
14
|
+
from matplotlib.pylab import Rectangle, gca, gcf, figure, ylabel, axes, draw
|
|
12
15
|
from matplotlib import rcParams
|
|
13
16
|
from matplotlib.font_manager import FontManager, _log as fm_logger
|
|
14
17
|
from matplotlib.lines import Line2D, TICKLEFT, TICKRIGHT
|
|
15
18
|
from matplotlib.ticker import FuncFormatter, FixedLocator
|
|
19
|
+
from matplotlib.image import imread
|
|
16
20
|
|
|
17
21
|
from hikyuu import *
|
|
22
|
+
from hikyuu import constant, isnan, Indicator, KData, IF
|
|
18
23
|
|
|
19
24
|
from .common import get_draw_title
|
|
20
25
|
|
|
21
26
|
|
|
27
|
+
ICON_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
28
|
+
|
|
29
|
+
|
|
22
30
|
def set_mpl_params():
|
|
23
31
|
'''设置交互及中文环境参数'''
|
|
24
32
|
if in_interactive_session():
|
|
25
33
|
rcParams['interactive'] = True
|
|
26
34
|
|
|
35
|
+
if sys.platform == 'darwin':
|
|
36
|
+
matplotlib.rcParams['font.sans-serif'] = 'Arial Unicode MS'
|
|
37
|
+
return
|
|
38
|
+
|
|
27
39
|
rcParams['font.family'] = 'sans-serif'
|
|
28
40
|
rcParams['axes.unicode_minus'] = False
|
|
29
41
|
|
|
30
|
-
expected_fonts = ['Microsoft YaHei', 'SimSun', 'SimHei',
|
|
42
|
+
expected_fonts = ['Microsoft YaHei', 'SimSun', 'SimHei',
|
|
43
|
+
'Source Han Sans CN', 'Noto Sans CJK JP', 'Arial Unicode MS']
|
|
31
44
|
current_fonts = matplotlib.rcParams['font.sans-serif']
|
|
32
45
|
for font in expected_fonts:
|
|
33
46
|
if font in current_fonts:
|
|
@@ -58,7 +71,7 @@ def create_two_axes_figure(figsize=(10, 8)):
|
|
|
58
71
|
"""生成一个含有2个坐标轴的figure,并返回坐标轴列表
|
|
59
72
|
|
|
60
73
|
:param figsize: (宽, 高)
|
|
61
|
-
:return: (ax1, ax2)
|
|
74
|
+
:return: (ax1, ax2)
|
|
62
75
|
"""
|
|
63
76
|
rect1 = [0.05, 0.35, 0.9, 0.60]
|
|
64
77
|
rect2 = [0.05, 0.05, 0.9, 0.30]
|
|
@@ -334,6 +347,7 @@ def iplot(
|
|
|
334
347
|
text_color='k',
|
|
335
348
|
zero_on=False,
|
|
336
349
|
label=None,
|
|
350
|
+
linestyle='-',
|
|
337
351
|
*args,
|
|
338
352
|
**kwargs
|
|
339
353
|
):
|
|
@@ -364,7 +378,7 @@ def iplot(
|
|
|
364
378
|
label = "%s %.2f" % (indicator.long_name, indicator[-1])
|
|
365
379
|
|
|
366
380
|
py_indicatr = [None if x == constant.null_price else x for x in indicator]
|
|
367
|
-
axes.plot(py_indicatr,
|
|
381
|
+
axes.plot(py_indicatr, linestyle=linestyle, label=label, *args, **kwargs)
|
|
368
382
|
|
|
369
383
|
if legend_on:
|
|
370
384
|
leg = axes.legend(loc='upper left')
|
|
@@ -830,3 +844,538 @@ def sys_performance(sys, ref_stk=None):
|
|
|
830
844
|
ax3.xaxis.set_visible(False)
|
|
831
845
|
ax3.yaxis.set_visible(False)
|
|
832
846
|
ax3.set_frame_on(False)
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
# ============================================================================
|
|
850
|
+
# 通达信画图函数
|
|
851
|
+
# ============================================================================
|
|
852
|
+
|
|
853
|
+
DRAWNULL = constant.null_price
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
def RGB(r: int, g: int, b: int):
|
|
857
|
+
hku_check(0 <= r <= 255 and 0 <= g <= 255 and 0 <= b <= 255, "r,g,b must in [0,255]!")
|
|
858
|
+
return f"#{r:02x}{g:02x}{b:02x}"
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
def STICKLINE(cond: Indicator, price1: Indicator, price2: Indicator, width: int = 2.0,
|
|
862
|
+
empty: bool = False, color='m', alpha=1.0, kdata=None, new=False, axes=None):
|
|
863
|
+
"""在满足cond的条件下,在 price1 和 price2 之间绘制一个宽度为 width 的柱状图。
|
|
864
|
+
|
|
865
|
+
注意: cond, price1, price2 应含有数据,否则请指定 kdata 作为指标计算的上下文
|
|
866
|
+
|
|
867
|
+
参数说明:
|
|
868
|
+
cond (Indicator): 条件表达式,用于确定是否绘制柱状线
|
|
869
|
+
price1 (Indicator): 第一个价格
|
|
870
|
+
price2 (Indicator): 第二个价格
|
|
871
|
+
width (int, optional): 柱状宽度. Defaults to 2.0.
|
|
872
|
+
empty (bool, optional): 空心. Defaults to False.
|
|
873
|
+
kdata (_type_, optional): 指定的上下文K线. Defaults to None.
|
|
874
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
875
|
+
axes (_type_, optional): 在指定的坐标轴中绘制. Defaults to None.
|
|
876
|
+
color (str, optional): 颜色. Defaults to 'm'.
|
|
877
|
+
alpha (float, optional): 透明度. Defaults to 1.0.
|
|
878
|
+
"""
|
|
879
|
+
hku_check(cond is not None and price1 is not None and price2 is not None, "cond, price1, price2 cannot be None")
|
|
880
|
+
|
|
881
|
+
if kdata is not None:
|
|
882
|
+
cond = cond(kdata)
|
|
883
|
+
price1 = price1(kdata)
|
|
884
|
+
price2 = price2(kdata)
|
|
885
|
+
hku_check(len(cond) == len(price1) == len(price2), "cond, price1, price2 length not match")
|
|
886
|
+
hku_warn_if(len(cond) <= 0, "cond, price1, price2 length <=0")
|
|
887
|
+
|
|
888
|
+
if axes is None:
|
|
889
|
+
axes = create_figure() if new else gca()
|
|
890
|
+
|
|
891
|
+
width = 0.3 * width
|
|
892
|
+
OFFSET = width / 2.0
|
|
893
|
+
for i in range(len(cond)):
|
|
894
|
+
if cond[i] > 0.:
|
|
895
|
+
height = abs(price1[i] - price2[i])
|
|
896
|
+
lower = min(price1[i], price2[i])
|
|
897
|
+
rect = Rectangle(xy=(i - OFFSET, lower), width=width, height=height,
|
|
898
|
+
facecolor=color, edgecolor=color, fill=(not empty))
|
|
899
|
+
rect.set_alpha(alpha)
|
|
900
|
+
axes.add_patch(rect)
|
|
901
|
+
|
|
902
|
+
axes.autoscale_view()
|
|
903
|
+
axes.set_xlim(-1, len(cond) + 1)
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
def DRAWBAND(val1: Indicator, color1='m', val2: Indicator = None, color2='b', kdata=None, alpha=0.2, new=False, axes=None, linestyle='-'):
|
|
907
|
+
"""画出带状线
|
|
908
|
+
|
|
909
|
+
用法:DRAWBAND(val1, color1, val2, color2), 当 val1 > val2 时,在 val1 和 val2 之间填充 color1;
|
|
910
|
+
当 val1 < val2 时,填充 color2,这里的颜色均使用 matplotlib 颜色代码.
|
|
911
|
+
例如:DRAWBAND(OPEN, 'r', CLOSE, 'b')
|
|
912
|
+
|
|
913
|
+
Args:
|
|
914
|
+
val1 (Indicator): 指标1
|
|
915
|
+
color1 (str, optional): 颜色1. Defaults to 'm'.
|
|
916
|
+
val2 (Indicator, optional): 指标2. Defaults to None.
|
|
917
|
+
color2 (str, optional): 颜色2. Defaults to 'b'.
|
|
918
|
+
kdata (_type_, optional): 指定指标上下文. Defaults to None.
|
|
919
|
+
alpha (float, optional): 透明度. Defaults to 0.2.
|
|
920
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
921
|
+
axes (_type_, optional): 在指定的坐标轴中绘制. Defaults to None.
|
|
922
|
+
linestyle (str, optional): 包络线类型. Defaults to '-'.
|
|
923
|
+
"""
|
|
924
|
+
hku_check(val1 is not None, "val1 cannot be None")
|
|
925
|
+
|
|
926
|
+
if kdata is not None:
|
|
927
|
+
val1 = val1(kdata)
|
|
928
|
+
if val2 is not None:
|
|
929
|
+
val2 = val2(kdata)
|
|
930
|
+
|
|
931
|
+
if val2 is None:
|
|
932
|
+
val2 = CVAL(val1, 0.)
|
|
933
|
+
|
|
934
|
+
hku_check(len(val1) == len(val2), "val1, val2 length not match")
|
|
935
|
+
hku_warn_if(len(val1) <= 0, "val1, val2 length <=0")
|
|
936
|
+
|
|
937
|
+
if axes is None:
|
|
938
|
+
axes = create_figure() if new else gca()
|
|
939
|
+
|
|
940
|
+
cond = IF(val1 <= val2, val1, val2)
|
|
941
|
+
axes.fill_between(range(cond.discard, len(val1)), val1[cond.discard:], cond[cond.discard:], alpha=alpha,
|
|
942
|
+
color=color1, facecolor=color1, edgecolor=color1, linestyle=linestyle)
|
|
943
|
+
|
|
944
|
+
cond = IF(val1 > val2, val1, val2)
|
|
945
|
+
axes.fill_between(range(cond.discard, len(val1)), val1[cond.discard:], cond[cond.discard:], alpha=alpha,
|
|
946
|
+
color=color2, facecolor=color2, edgecolor=color2, linestyle=linestyle)
|
|
947
|
+
|
|
948
|
+
axes.autoscale_view()
|
|
949
|
+
axes.set_xlim(-1, len(val1) + 1)
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
def PLOYLINE(cond: Indicator, price: Indicator, kdata: KData = None, color: str = 'm', linewidth=1.0, new=False, axes=None, *args, **kwargs):
|
|
953
|
+
"""在图形上绘制折线段。
|
|
954
|
+
|
|
955
|
+
用法:PLOYLINE(COND,PRICE),当COND条件满足时,以PRICE位置为顶点画折线连接。
|
|
956
|
+
例如:PLOYLINE(HIGH>=HHV(HIGH,20),HIGH, kdata=k)表示在创20天新高点之间画折线。
|
|
957
|
+
|
|
958
|
+
Args:
|
|
959
|
+
cond (Indicator): 指定条件
|
|
960
|
+
price (Indicator): 位置
|
|
961
|
+
kdata (KData, optional): 指定的上下文. Defaults to None.
|
|
962
|
+
color (str, optional): 颜色. Defaults to 'b'.
|
|
963
|
+
linewidth (float, optional): 宽度. Defaults to 1.0.
|
|
964
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
965
|
+
axes (_type_, optional): 指定的axes. Defaults to None.
|
|
966
|
+
"""
|
|
967
|
+
hku_check(cond is not None and price is not None, "cond, price cannot be None")
|
|
968
|
+
|
|
969
|
+
ind = IF(cond, price, constant.null_price)
|
|
970
|
+
if kdata is not None:
|
|
971
|
+
ind = ind(kdata)
|
|
972
|
+
price = price(kdata)
|
|
973
|
+
hku_check(len(ind) == len(price), "cond, price length not match!")
|
|
974
|
+
hku_warn_if(len(ind) <= 0, "cond length <=0")
|
|
975
|
+
|
|
976
|
+
if axes is None:
|
|
977
|
+
axes = create_figure() if new else gca()
|
|
978
|
+
|
|
979
|
+
# ind.plot(new=new, axes=axes, color=color, linewidth=linewidth, *args, **kwargs)
|
|
980
|
+
x, y = [], []
|
|
981
|
+
for i in range(ind.discard, len(ind)):
|
|
982
|
+
val = ind[i]
|
|
983
|
+
if not isnan(val):
|
|
984
|
+
x.append(i)
|
|
985
|
+
y.append(val)
|
|
986
|
+
if len(x) > 0:
|
|
987
|
+
axes.plot(x, y, color=color, linewidth=linewidth, *args, **kwargs)
|
|
988
|
+
|
|
989
|
+
axes.autoscale_view()
|
|
990
|
+
axes.set_xlim(-1, len(ind) + 1)
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
def DRAWLINE(cond1: Indicator, price1: Indicator, cond2: Indicator, price2: Indicator, expand: int = 0, kdata: KData = None, color: str = 'm', new=False, axes=None, *args, **kwargs):
|
|
994
|
+
"""在图形上绘制直线段。
|
|
995
|
+
|
|
996
|
+
用法:DRAWLINE(cond1, price1, cond2, price2, expand)
|
|
997
|
+
当COND1条件满足时,在PRICE1位置画直线起点,当COND2条件满足时,在PRICE2位置画直线终点,EXPAND为延长类型。
|
|
998
|
+
例如:DRAWLINE(HIGH>=HHV(HIGH,20),HIGH,LOW<=LLV(LOW,20),LOW,1)表示在创20天新高与创20天新低之间画直线并且向右延长
|
|
999
|
+
|
|
1000
|
+
Args:
|
|
1001
|
+
cond1 (Indicator): 条件1
|
|
1002
|
+
price1 (Indicator): 位置1
|
|
1003
|
+
cond2 (Indicator): 条件2
|
|
1004
|
+
price2 (Indicator): 位置2
|
|
1005
|
+
expand (int, optional): 0: 不延长 | 1: 向右延长 | 10: 向左延长 | 11: 双向延长. Defaults to 0.
|
|
1006
|
+
kdata (KData, optional): 指定的上下文. Defaults to None.
|
|
1007
|
+
color (str, optional): 指定颜色. Defaults to 'm'.
|
|
1008
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1009
|
+
axes (_type_, optional): 指定的坐标轴. Defaults to None.
|
|
1010
|
+
"""
|
|
1011
|
+
hku_check(cond1 is not None and cond2 is not None and price1 is not None and price2 is not None,
|
|
1012
|
+
"cond1, cond2, price1, price2 cannot be None")
|
|
1013
|
+
hku_check(expand in (0, 1, 10, 11), "expand must be 0, 1, 10 or 11")
|
|
1014
|
+
|
|
1015
|
+
if kdata is not None:
|
|
1016
|
+
cond1 = cond1(kdata)
|
|
1017
|
+
price1 = price1(kdata)
|
|
1018
|
+
cond2 = cond2(kdata)
|
|
1019
|
+
price2 = price2(kdata)
|
|
1020
|
+
hku_check(len(cond1) == len(cond2) == len(price1) == len(price2), "cond1, cond2, price1, price2 length not match")
|
|
1021
|
+
hku_warn_if(len(cond1) <= 0, "cond1, cond2, price1, price2 length <=0")
|
|
1022
|
+
|
|
1023
|
+
if axes is None:
|
|
1024
|
+
axes = create_figure() if new else gca()
|
|
1025
|
+
|
|
1026
|
+
length = len(cond1)
|
|
1027
|
+
x1, y1 = None, None
|
|
1028
|
+
for i in range(cond1.discard, length):
|
|
1029
|
+
cond1_val = cond1[i]
|
|
1030
|
+
if cond1_val > 0.:
|
|
1031
|
+
if x1 is None:
|
|
1032
|
+
x1, y1 = i, price1[i]
|
|
1033
|
+
else:
|
|
1034
|
+
x1, y1 = None, None
|
|
1035
|
+
cond2_val = cond2[i]
|
|
1036
|
+
if cond2_val > 0.:
|
|
1037
|
+
if x1 is not None:
|
|
1038
|
+
if expand == 0:
|
|
1039
|
+
x = [x1, i]
|
|
1040
|
+
y = [y1, price2[i]]
|
|
1041
|
+
elif expand == 1:
|
|
1042
|
+
x = [n for n in range(i, length)]
|
|
1043
|
+
x.insert(0, x1)
|
|
1044
|
+
val = price2[i]
|
|
1045
|
+
y = [val for n in range(i, length)]
|
|
1046
|
+
y.insert(0, y1)
|
|
1047
|
+
elif expand == 10:
|
|
1048
|
+
x = [n for n in range(0, i+1)]
|
|
1049
|
+
val = price2[i]
|
|
1050
|
+
y = [val for n in range(0, i+1)]
|
|
1051
|
+
elif expand == 11:
|
|
1052
|
+
x = [n for n in range(0, length)]
|
|
1053
|
+
val = price2[i]
|
|
1054
|
+
y = [val for n in range(0, length)]
|
|
1055
|
+
axes.plot(x, y, color=color, *args, **kwargs)
|
|
1056
|
+
x1, y1 = None, None
|
|
1057
|
+
|
|
1058
|
+
axes.autoscale_view()
|
|
1059
|
+
axes.set_xlim(-1, len(cond1) + 1)
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
def DRAWTEXT(cond: Indicator, price: Indicator, text: str, kdata: KData = None, color: str = 'm', new=False, axes=None, *args, **kwargs):
|
|
1063
|
+
"""在图形上显示文字。
|
|
1064
|
+
|
|
1065
|
+
用法: DRAWTEXT(cond, price, text), 当 cond 条件满足时, 在 price 位置书写文字 text。
|
|
1066
|
+
例如: DRAWTEXT(CLOSE/OPEN>1.08,LOW,'大阳线')表示当日实体阳线大于8%时在最低价位置显示'大阳线'字样.
|
|
1067
|
+
|
|
1068
|
+
Args:
|
|
1069
|
+
cond (Indicator): 条件
|
|
1070
|
+
price (Indicator): 显示位置
|
|
1071
|
+
text (str): 待显示文字
|
|
1072
|
+
kdata (KData, optional): 指定的上下文. Defaults to None.
|
|
1073
|
+
color (str, optional): 指定颜色. Defaults to 'm'.
|
|
1074
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1075
|
+
axes (_type_, optional): 指定的坐标轴. Defaults to None.
|
|
1076
|
+
"""
|
|
1077
|
+
hku_check(cond is not None and price is not None, "cond, price cannot be None")
|
|
1078
|
+
|
|
1079
|
+
if kdata is not None:
|
|
1080
|
+
cond = cond(kdata)
|
|
1081
|
+
price = price(kdata)
|
|
1082
|
+
hku_check(len(cond) == len(price), "cond, price length not match")
|
|
1083
|
+
hku_warn_if(len(cond) <= 0, "cond length <=0")
|
|
1084
|
+
|
|
1085
|
+
if axes is None:
|
|
1086
|
+
axes = create_figure() if new else gca()
|
|
1087
|
+
|
|
1088
|
+
for i in range(cond.discard, len(cond)):
|
|
1089
|
+
if cond[i] > 0.:
|
|
1090
|
+
axes.text(i, price[i], text, color=color, *args, **kwargs)
|
|
1091
|
+
|
|
1092
|
+
axes.autoscale_view()
|
|
1093
|
+
axes.set_xlim(-1, len(cond) + 1)
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
def DRAWTEXT_FIX(cond: Indicator, x: float, y: float, type: int, text: str, kdata: KData = None, color: str = 'm', new=False, axes=None, *args, **kwargs):
|
|
1097
|
+
"""固定位置显示文字
|
|
1098
|
+
|
|
1099
|
+
用法:DRAWTEXT_FIX(cond,x y, text), cond 中一般需要加 ISLASTBAR,当 cond 条件满足时,
|
|
1100
|
+
在当前指标窗口内(X,Y)位置书写文字TEXT,X,Y为书写点在窗口中相对于左上角的百分比
|
|
1101
|
+
|
|
1102
|
+
例如:DRAWTEXT_FIX(ISLASTBAR() & (CLOSE/OPEN>1.08),0.5,0.5,0,'大阳线')表示最后一个交易日实体阳线
|
|
1103
|
+
大于8%时在窗口中间位置显示'大阳线'字样.
|
|
1104
|
+
|
|
1105
|
+
Args:
|
|
1106
|
+
cond (Indicator): 条件
|
|
1107
|
+
x (float): x轴坐标
|
|
1108
|
+
y (float): y轴坐标
|
|
1109
|
+
type (int, optional): 0 左对齐 | 1 右对齐.
|
|
1110
|
+
text (str): 待显示文字
|
|
1111
|
+
kdata (KData, optional): 指定的上下文. Defaults to None.
|
|
1112
|
+
color (str, optional): 指定颜色. Defaults to 'm'.
|
|
1113
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1114
|
+
axes (_type_, optional): 指定坐标轴. Defaults to None.
|
|
1115
|
+
"""
|
|
1116
|
+
hku_check(cond is not None, "cond cannot be None")
|
|
1117
|
+
if kdata is not None:
|
|
1118
|
+
cond = cond(kdata)
|
|
1119
|
+
hku_warn_if(len(cond) <= 0, "cond length <=0")
|
|
1120
|
+
|
|
1121
|
+
if axes is None:
|
|
1122
|
+
axes = create_figure() if new else gca()
|
|
1123
|
+
|
|
1124
|
+
for i in range(cond.discard, len(cond)):
|
|
1125
|
+
if cond[i] > 0.:
|
|
1126
|
+
axes.text(x, 1-y, text, horizontalalignment='left' if type == 0 else 'right', verticalalignment='top',
|
|
1127
|
+
transform=axes.transAxes, color=color, *args, **kwargs)
|
|
1128
|
+
|
|
1129
|
+
axes.autoscale_view()
|
|
1130
|
+
axes.set_xlim(-1, len(cond) + 1)
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
def DRAWNUMBER(cond: Indicator, price: Indicator, number: Indicator, kdata: KData = None, color: str = 'm', new=False, axes=None, *args, **kwargs):
|
|
1134
|
+
"""画出数字.
|
|
1135
|
+
|
|
1136
|
+
用法:DRAWNUMBER(cond, price, number),当 cond 条件满足时,在 price 位置书写数字 number.
|
|
1137
|
+
例如:DRAWNUMBER(CLOSE/OPEN>1.08,LOW,C)表示当日实体阳线大于8%时在最低价位置显示收盘价。
|
|
1138
|
+
|
|
1139
|
+
Args:
|
|
1140
|
+
cond (Indicator): 条件
|
|
1141
|
+
price (Indicator): 绘制位置
|
|
1142
|
+
number (Indicator): 待绘制数字
|
|
1143
|
+
kdata (KData, optional): 指定的上下文. Defaults to None.
|
|
1144
|
+
color (str, optional): 指定颜色. Defaults to 'm'.
|
|
1145
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1146
|
+
axes (_type_, optional): 指定的坐标轴. Defaults to None.
|
|
1147
|
+
"""
|
|
1148
|
+
hku_check(cond is not None and price is not None, "cond, price cannot be None")
|
|
1149
|
+
|
|
1150
|
+
if kdata is not None:
|
|
1151
|
+
cond = cond(kdata)
|
|
1152
|
+
price = price(kdata)
|
|
1153
|
+
number = number(kdata)
|
|
1154
|
+
hku_check(len(cond) == len(price), "cond, price, number length not match")
|
|
1155
|
+
hku_warn_if(len(cond) <= 0, "cond length <=0")
|
|
1156
|
+
|
|
1157
|
+
if axes is None:
|
|
1158
|
+
axes = create_figure() if new else gca()
|
|
1159
|
+
|
|
1160
|
+
for i in range(cond.discard, len(cond)):
|
|
1161
|
+
if cond[i] > 0.:
|
|
1162
|
+
axes.text(i, price[i], str(number[i]), color=color, *args, **kwargs)
|
|
1163
|
+
|
|
1164
|
+
axes.autoscale_view()
|
|
1165
|
+
axes.set_xlim(-1, len(cond) + 1)
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
def DRAWNUMBER_FIX(cond: Indicator, x: float, y: float, type: int, number: float, kdata: KData = None, color: str = 'm', new=False, axes=None, *args, **kwargs):
|
|
1169
|
+
"""固定位置显示数字.
|
|
1170
|
+
|
|
1171
|
+
用法:DRAWNUMBER_FIX(cond,x,y,type,number), cond 中一般需要加 ISLASTBAR, 当 cond 条件满足时,
|
|
1172
|
+
在当前指标窗口内 (x, y) 位置书写数字 number, x,y为书写点在窗口中相对于左上角的百分比,type:0为左对齐,1为右对齐。
|
|
1173
|
+
|
|
1174
|
+
例如:DRAWNUMBER_FIX(ISLASTBAR() & (CLOSE/OPEN>1.08), 0.5,0.5,0,C)表示最后一个交易日实体阳线大于8%时在窗口中间位置显示收盘价
|
|
1175
|
+
|
|
1176
|
+
Args:
|
|
1177
|
+
cond (Indicator): _description_
|
|
1178
|
+
x (float): _description_
|
|
1179
|
+
y (float): _description_
|
|
1180
|
+
type (int): _description_
|
|
1181
|
+
number (Indicator): _description_
|
|
1182
|
+
kdata (KData, optional): _description_. Defaults to None.
|
|
1183
|
+
color (str, optional): _description_. Defaults to 'm'.
|
|
1184
|
+
new (bool, optional): _description_. Defaults to False.
|
|
1185
|
+
axes (_type_, optional): _description_. Defaults to None.
|
|
1186
|
+
"""
|
|
1187
|
+
DRAWTEXT_FIX(cond, x, y, type, str(number), kdata, color, new, axes, *args, **kwargs)
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
def DRAWSL(cond: Indicator, price: Indicator, slope: Union[Indicator, float, int], length: Union[Indicator, float, int], direct: int, kdata: KData = None, color: str = 'm', new=False, axes=None, *args, **kwargs):
|
|
1191
|
+
"""绘制斜线.
|
|
1192
|
+
|
|
1193
|
+
用法:DRAWSL(cond,price,slope,length,diect),当 cond 条件满足时,在 price 位置画斜线, slope 为斜率,
|
|
1194
|
+
lengh为长度, direct 为0向右延伸,1向左延伸,2双向延伸。
|
|
1195
|
+
|
|
1196
|
+
注意:
|
|
1197
|
+
1. K线间的纵向高度差为 slope;
|
|
1198
|
+
2. slope 为 0 时, 为水平线;
|
|
1199
|
+
3. slope 为 10000 时, 为垂直线, length 为向上的像素高度, direct 表示向上或向下延伸
|
|
1200
|
+
4. slope 和 length 支持变量;
|
|
1201
|
+
|
|
1202
|
+
Args:
|
|
1203
|
+
cond (Indicator): 条件指标
|
|
1204
|
+
price (Indicator): 价格
|
|
1205
|
+
slope (int|float|Indicator): 斜率
|
|
1206
|
+
length (int|float|Indicator): 长度
|
|
1207
|
+
direct (int): 方向
|
|
1208
|
+
kdata (KData, optional): 指定的上下文. Defaults to None.
|
|
1209
|
+
color (str, optional): 颜色. Defaults to 'm'.
|
|
1210
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1211
|
+
axes (_type_, optional): 指定的坐标轴. Defaults to None.
|
|
1212
|
+
"""
|
|
1213
|
+
hku_check(cond is not None and price is not None, "cond, price cannot be None")
|
|
1214
|
+
hku_check(direct in (0, 1, 2), "direct must be 0,1,2")
|
|
1215
|
+
|
|
1216
|
+
if kdata is not None:
|
|
1217
|
+
cond = cond(kdata)
|
|
1218
|
+
price = price(kdata)
|
|
1219
|
+
slope = slope(kdata) if isinstance(slope, Indicator) else [slope for i in range(len(kdata))]
|
|
1220
|
+
length = length(kdata) if isinstance(length, Indicator) else [length for i in range(len(kdata))]
|
|
1221
|
+
|
|
1222
|
+
hku_check(len(cond) == len(price), "cond, price length not match")
|
|
1223
|
+
hku_warn_if(len(cond) <= 0, "cond length <=0")
|
|
1224
|
+
|
|
1225
|
+
if axes is None:
|
|
1226
|
+
axes = create_figure() if new else gca()
|
|
1227
|
+
|
|
1228
|
+
for i in range(cond.discard, len(cond)):
|
|
1229
|
+
val = price[i]
|
|
1230
|
+
if not isnan(val):
|
|
1231
|
+
if slope[i] < 10000:
|
|
1232
|
+
x = length[i] / math.sqrt(1+slope[i]**2)
|
|
1233
|
+
y = x * slope[i]
|
|
1234
|
+
if direct == 0:
|
|
1235
|
+
axes.plot([i, i+x], [val, val+y], color=color, *args, **kwargs)
|
|
1236
|
+
elif direct == 1:
|
|
1237
|
+
axes.plot([i-x, i], [val-y, val], color=color, *args, **kwargs)
|
|
1238
|
+
else:
|
|
1239
|
+
axes.plot([i-x*0.5, i, i+x*0.5], [val-y*0.5, val, val+y*0.5], color=color, *args, **kwargs)
|
|
1240
|
+
else:
|
|
1241
|
+
y = length[i]
|
|
1242
|
+
if direct == 0:
|
|
1243
|
+
axes.plot([i, i], [val, val+y], color=color, *args, **kwargs)
|
|
1244
|
+
elif direct == 1:
|
|
1245
|
+
axes.plot([i, i], [val, val-y], color=color, *args, **kwargs)
|
|
1246
|
+
else:
|
|
1247
|
+
axes.plot([i, i, i], [val-y*0.5, val, val+y*0.5], color=color, *args, **kwargs)
|
|
1248
|
+
|
|
1249
|
+
axes.autoscale_view()
|
|
1250
|
+
axes.set_xlim(-1, len(cond) + 1)
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
def DRAWIMG(cond: Indicator, price: Indicator, img: str, kdata: KData = None, new=False, axes=None, *args, **kwargs):
|
|
1254
|
+
"""画图片
|
|
1255
|
+
|
|
1256
|
+
用法:DRAWIMG(cond,price,'图像文件文件名'),当条件 cond 满足时,在 price 位置画指定的图片
|
|
1257
|
+
例如:DRAWIMG(O>C,CLOSE, '123.png')。
|
|
1258
|
+
|
|
1259
|
+
Args:
|
|
1260
|
+
cond (Indicator): 指定条件
|
|
1261
|
+
price (Indicator): 指定价格
|
|
1262
|
+
img (str): 图像文件名
|
|
1263
|
+
kdata (KData, optional): 指定上下文. Defaults to None.
|
|
1264
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1265
|
+
axes (_type_, optional): 在指定坐标轴中绘制. Defaults to None.
|
|
1266
|
+
"""
|
|
1267
|
+
hku_check(cond is not None and price is not None, "cond, price cannot be None")
|
|
1268
|
+
|
|
1269
|
+
if kdata is not None:
|
|
1270
|
+
cond = cond(kdata)
|
|
1271
|
+
price = price(kdata)
|
|
1272
|
+
hku_check(len(cond) == len(price), "cond, price length not match")
|
|
1273
|
+
hku_warn_if(len(cond) <= 0, "cond length <=0")
|
|
1274
|
+
|
|
1275
|
+
if axes is None:
|
|
1276
|
+
axes = create_figure() if new else gca()
|
|
1277
|
+
|
|
1278
|
+
image = imread(img)
|
|
1279
|
+
|
|
1280
|
+
p = axes.get_window_extent()
|
|
1281
|
+
pw = p.x1 - p.x0
|
|
1282
|
+
ph = p.y1 - p.y0
|
|
1283
|
+
x0, x1 = axes.get_xlim()
|
|
1284
|
+
y0, y1 = axes.get_ylim()
|
|
1285
|
+
xw = x1 - x0
|
|
1286
|
+
yh = y1 - y0
|
|
1287
|
+
pixel = 20. # 显示像素大小
|
|
1288
|
+
w = xw / pw * pixel
|
|
1289
|
+
h = yh / ph * pixel
|
|
1290
|
+
for i in range(cond.discard, len(cond)):
|
|
1291
|
+
if cond[i] > 0.:
|
|
1292
|
+
axes.imshow(image, extent=[i-w, i+w, price[i]-h, price[i]+h], *args, **kwargs)
|
|
1293
|
+
|
|
1294
|
+
axes.set_aspect('auto')
|
|
1295
|
+
axes.autoscale_view()
|
|
1296
|
+
axes.set_ylim(y0, y1)
|
|
1297
|
+
axes.set_xlim(-1, len(cond) + 1)
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
DRAWBMP = DRAWIMG
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
def DRAWICON(cond: Indicator, price: Indicator, type: int, kdata: KData = None, new=False, axes=None, *args, **kwargs):
|
|
1304
|
+
DRAWIMG(cond, price, f'{ICON_PATH}/icon/{type}.png', kdata, new, axes, *args, **kwargs)
|
|
1305
|
+
|
|
1306
|
+
|
|
1307
|
+
def SHOWICONS():
|
|
1308
|
+
"""显示所有内置图标"""
|
|
1309
|
+
axes = create_one_axes_figure([8, 6])
|
|
1310
|
+
p = axes.get_window_extent()
|
|
1311
|
+
pw = p.x1 - p.x0
|
|
1312
|
+
ph = p.y1 - p.y0
|
|
1313
|
+
x0, x1 = axes.get_xlim()
|
|
1314
|
+
y0, y1 = axes.get_ylim()
|
|
1315
|
+
xw = x1 - x0
|
|
1316
|
+
yh = y1 - y0
|
|
1317
|
+
pixel = 100. # 显示像素大小
|
|
1318
|
+
w = xw / pw * pixel
|
|
1319
|
+
h = yh / ph * pixel
|
|
1320
|
+
|
|
1321
|
+
row, col = 5, 10
|
|
1322
|
+
for i in range(row):
|
|
1323
|
+
for j in range(col):
|
|
1324
|
+
n = i*col+j + 1
|
|
1325
|
+
name = f'{ICON_PATH}/icon/{n}.png'
|
|
1326
|
+
if os.path.exists(name):
|
|
1327
|
+
try:
|
|
1328
|
+
x = j*w
|
|
1329
|
+
y = i*h
|
|
1330
|
+
axes.imshow(imread(name), extent=[x, x+w, 1-(y+h), 1-y])
|
|
1331
|
+
except:
|
|
1332
|
+
pass
|
|
1333
|
+
axes.set_aspect('auto')
|
|
1334
|
+
axes.autoscale_view()
|
|
1335
|
+
axes.set_ylim(y0, y1)
|
|
1336
|
+
axes.set_xlim(x0, x1)
|
|
1337
|
+
|
|
1338
|
+
|
|
1339
|
+
def DRAWRECTREL(left: int, top: int, right: int, bottom: int, color='m', frame=True, fill=True, alpha=0.1, new=False, axes=None, *args, **kwargs):
|
|
1340
|
+
"""相对位置上画矩形.
|
|
1341
|
+
|
|
1342
|
+
注意:原点为坐标轴左上角(0, 0),和 matplotlib 不同。
|
|
1343
|
+
用法: DRAWRECTREL(left,top,right,bottom,color), 以图形窗口 (left, top) 为左上角, (right, bottom) 为
|
|
1344
|
+
右下角绘制矩形, 坐标单位是窗口沿水平和垂直方向的1/1000,取值范围是0—999,超出范围则可能显示在图形窗口外,矩形
|
|
1345
|
+
中间填充颜色COLOR,COLOR为0表示不填充.
|
|
1346
|
+
例如:DRAWRECTREL(0,0,500,500,RGB(255,255,0)) 表示在图形最左上部1/4位置用黄色绘制矩形
|
|
1347
|
+
|
|
1348
|
+
Args:
|
|
1349
|
+
left (int): 左上角x
|
|
1350
|
+
top (int): 左上角y
|
|
1351
|
+
right (int): 右下角x
|
|
1352
|
+
bottom (int): 右下角y
|
|
1353
|
+
color (str, optional): 指定颜色. Defaults to 'm'.
|
|
1354
|
+
frame (bool, optional): 添加边框. Defaults to False.
|
|
1355
|
+
fill (bool, optional): 颜色填充. Defaults to True.
|
|
1356
|
+
alpha (float, optional): 透明度. Defaults to 0.1.
|
|
1357
|
+
new (bool, optional): 在新窗口中绘制. Defaults to False.
|
|
1358
|
+
axes (_type_, optional): 指定的坐标轴. Defaults to None.
|
|
1359
|
+
"""
|
|
1360
|
+
if axes is None:
|
|
1361
|
+
axes = create_figure() if new else gca()
|
|
1362
|
+
|
|
1363
|
+
x0, x1 = axes.get_xlim()
|
|
1364
|
+
y0, y1 = axes.get_ylim()
|
|
1365
|
+
w = x1 - x0
|
|
1366
|
+
h = y1 - y0
|
|
1367
|
+
|
|
1368
|
+
limit = 1000
|
|
1369
|
+
cx = w / limit
|
|
1370
|
+
cy = h / limit
|
|
1371
|
+
x = left * cx + x0
|
|
1372
|
+
y = (limit - bottom) * cy + y0
|
|
1373
|
+
width = (right - left) * cx
|
|
1374
|
+
height = (bottom - top) * cy
|
|
1375
|
+
print(x, y, width, height)
|
|
1376
|
+
if frame:
|
|
1377
|
+
rect = Rectangle(xy=(x, y), width=width, height=height, facecolor=color, edgecolor=color, fill=fill)
|
|
1378
|
+
else:
|
|
1379
|
+
rect = Rectangle(xy=(x, y), width=width, height=height, facecolor=color, fill=fill)
|
|
1380
|
+
rect.set_alpha(alpha)
|
|
1381
|
+
axes.add_patch(rect)
|