コード例 #1
0
ファイル: matplotlib_draw.py プロジェクト: zklvyy/hikyuu
def iplot(indicator, new=True, axes=None, 
          legend_on=False, text_on=False, text_color='k',  
          zero_on=False, label=None, *args, **kwargs):
    """绘制indicator曲线
    
    :param Indicator indicator: indicator实例
    :param axes:            指定的坐标轴
    :param new:             是否在新窗口中显示,只在没有指定axes时生效
    :param legend_on:       是否打开图例
    :param text_on:         是否在左上角显示指标名称及其参数
    :param text_color:      指标名称解释文字的颜色,默认为黑色
    :param zero_on:         是否需要在y=0轴上绘制一条直线
    :param str label:       label显示文字信息,text_on 及 legend_on 为 True 时生效
    :param args:            pylab plot参数
    :param kwargs:          pylab plot参数,如:marker(标记类型)、
                             markerfacecolor(标记颜色)、
                             markeredgecolor(标记的边缘颜色)
    """
    if not indicator:
        print("indicator is None")
        return
    
    if not axes:
        axes = create_figure() if new else gca()
    
    if not label:
        label = "%s %.2f" % (indicator.long_name, indicator[-1])

    py_indicatr = [ None if x == constant.null_price else x for x in indicator]
    axes.plot(py_indicatr, '-', label=label, *args, **kwargs)
        
    if legend_on:
        leg = axes.legend(loc='upper left')
        leg.get_frame().set_alpha(0.5)
        
    if text_on:
        if not axes.texts:
            axes.text(0.01,0.97, label, horizontalalignment='left', verticalalignment='top', 
                      transform=axes.transAxes, color=text_color)
        else:
            temp_str = axes.texts[0].get_text() + '  ' + label
            axes.texts[0].set_text(temp_str)
        
    if zero_on:
        ylim = axes.get_ylim()
        if ylim[0]<0<ylim[1]:
            axes.hlines(0,0,len(indicator))

    axes.autoscale_view()
    axes.set_xlim(-1, len(indicator)+1)
コード例 #2
0
ファイル: matplotlib_draw.py プロジェクト: sibaba8888/hikyuu
def iplot(
    indicator,
    new=True,
    axes=None,
    legend_on=False,
    text_on=False,
    text_color='k',
    zero_on=False,
    label=None,
    *args,
    **kwargs
):
    """绘制indicator曲线
    
    :param Indicator indicator: indicator实例
    :param axes:            指定的坐标轴
    :param new:             是否在新窗口中显示,只在没有指定axes时生效
    :param legend_on:       是否打开图例
    :param text_on:         是否在左上角显示指标名称及其参数
    :param text_color:      指标名称解释文字的颜色,默认为黑色
    :param zero_on:         是否需要在y=0轴上绘制一条直线
    :param str label:       label显示文字信息,text_on 及 legend_on 为 True 时生效
    :param args:            pylab plot参数
    :param kwargs:          pylab plot参数,如:marker(标记类型)、
                             markerfacecolor(标记颜色)、
                             markeredgecolor(标记的边缘颜色)
    """
    if not indicator:
        print("indicator is None")
        return

    if not axes:
        axes = create_figure() if new else gca()

    if not label:
        label = "%s %.2f" % (indicator.long_name, indicator[-1])

    py_indicatr = [None if x == constant.null_price else x for x in indicator]
    axes.plot(py_indicatr, '-', label=label, *args, **kwargs)

    if legend_on:
        leg = axes.legend(loc='upper left')
        leg.get_frame().set_alpha(0.5)

    if text_on:
        if not axes.texts:
            axes.text(
                0.01,
                0.97,
                label,
                horizontalalignment='left',
                verticalalignment='top',
                transform=axes.transAxes,
                color=text_color
            )
        else:
            temp_str = axes.texts[0].get_text() + '  ' + label
            axes.texts[0].set_text(temp_str)

    if zero_on:
        ylim = axes.get_ylim()
        if ylim[0] < 0 < ylim[1]:
            axes.hlines(0, 0, len(indicator))

    axes.autoscale_view()
    axes.set_xlim(-1, len(indicator) + 1)
    k = indicator.get_context()
    if len(k) > 0:
        ax_set_locator_formatter(axes, k.get_date_list(), k.get_query().ktype)
コード例 #3
0
ファイル: plotresultsMBs.py プロジェクト: engbarakat/Gavel
axes.yaxis.grid(b=True, which='major', color='dimgray', linestyle='--',linewidth = 5.0)
axes.set_ylim([1,80000])
axes.set_xlim([0,16])
axes.set_xticks([1.5, 4.5, 7.5,10.5,13.5])
axes.set_xticklabels(['3', '4', '5','6','7'],color='black',size=35)
axes.tick_params(axis='y', colors='black',size=35)
    
for tic in axes.yaxis.get_major_ticks():
    tic.label.set_fontsize(35)
    
#for tic in axes[2].yaxis.get_major_ticks():
#    tic.label1On = tic.label2On = False
# set axes limits and labels


hB, = axes.plot([0,0],'g-',linewidth = 3.0)
hR, = axes.plot([0,0],'-',color='#C00000', linewidth = 3.0)
legend = legend((hB, hR),('Gavel', 'Ravel'),loc=(0.85, .7), labelspacing=0.1)
#plt.legend(loc=2,prop={'size':6})
hB.set_visible(False)
hR.set_visible(False)
ltext = plt.gca().get_legend().get_texts()
plt.setp(ltext[0], fontsize = 20, color = 'g')
plt.setp(ltext[1], fontsize = 20, color = '#C00000')
plt.tight_layout()
plt.subplots_adjust(bottom=0.1)
#plt.grid(b=True, which='both', color='dimgray',linestyle='-')
plt.setp(legend.get_texts(), fontsize='30')
plt.show()
コード例 #4
0
ファイル: drawplot.py プロジェクト: yunfeiz/hikyuu
def iplot(indicator,
          axes=None,
          new=True,
          legend_on=False,
          text_on=False,
          text_color='k',
          zero_on=False,
          label=None,
          *args,
          **kwargs):
    """绘制indicator曲线
    indicator: indicator实例
    axes: 指定的坐标轴
    new: 是否在新窗口中显示,只在没有指定axes时生效
    legend_on: 是否打开图例
    text_on: 是否在左上角显示指标名称及其参数
    text_color: 指标名称解释文字的颜色,默认为黑色
    marker:标记类型
    markerfacecolor:标记颜色
    markeredgecolor: 标记的边缘颜色
    zero_on: 是否需要在y=0轴上绘制一条直线
    label  : label
    *args, **kwargs : pylab plot参数
    """
    if not indicator:
        print("indicator is None")
        return

    if not axes:
        axes = create_one_axes_figure() if new else gca()

    if not label:
        label = "%s %.2f" % (indicator.long_name, indicator[-1])

    py_indicatr = [None if x == constant.null_price else x for x in indicator]
    axes.plot(py_indicatr, '-', label=label, *args, **kwargs)

    if legend_on:
        leg = axes.legend(loc='upper left')
        leg.get_frame().set_alpha(0.5)

    if text_on:
        if not axes.texts:
            axes.text(0.01,
                      0.97,
                      label,
                      horizontalalignment='left',
                      verticalalignment='top',
                      transform=axes.transAxes,
                      color=text_color)
        else:
            temp_str = axes.texts[0].get_text() + '  ' + label
            axes.texts[0].set_text(temp_str)

    if zero_on:
        ylim = axes.get_ylim()
        if ylim[0] < 0 < ylim[1]:
            axes.hlines(0, 0, len(indicator))

    axes.autoscale_view()
    axes.set_xlim(-1, len(indicator) + 1)