首页  

pandas matplot 画图 超出阈值 变颜色     所属分类 python 浏览量 36
import pandas as pd
import matplotlib.pyplot as plt  

data = [{'a':1,'b':1},{'a':2,'b':2},{'a':3,'b':5},
        {'a':4,'b':8},{'a':5,'b':9},{'a':6,'b':6},
        {'a':7,'b':5},{'a':8,'b':2},{'a':9,'b':9},
        {'a':10,'b':1}]
df = pd.DataFrame(data)
plt.plot(df.index,df['b']);
highmask = df[df.b > 3]

# plt.plot(highmask.index,highmask['b'],color='red');

# linestyle=''  不画线 
plt.plot(highmask.index,highmask['b'],color='red',linestyle='',marker='*');



# 买入信号 buymask = df[df['bias250']< -15] plt.plot(buymask['dt'],buymask['close'],color='red',linestyle='',marker='o') # 卖出信号 sellmask = df[df['bias250'] > 20] plt.plot(sellmask['dt'],sellmask['close'],color='g',linestyle='',marker='o')

上一篇     下一篇
matplotlib 技巧

matplot 基本用法

pandas matplot 读取日线数据,滚动计算bias250 添加阈值线

沪深300指数 bias250 z20 z250 分析

聚宽 沪深300指数 数据读取分析

油车 电车 使用成本