首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >线上的标记

线上的标记
EN

Stack Overflow用户
提问于 2017-04-16 17:19:32
回答 1查看 481关注 0票数 1

我有一个列表,由两个不同的数据组成,用于绘制两行,另一个列表由这些行上的标记组成。但是标记列表可以有空集。我写了一个代码,但它没有显示任何图像。有人能告诉我为什么下面的几句话不能用吗?

代码语言:javascript
复制
import numpy as np
import matplotlib.pyplot as plt

def Draw(Narratives, Prob_failure):        
    x=list(range(0,len(Narratives[0])))
    for i in range(len(Narratives)):
        plt.figure(figsize=(12,8))
        if not Prob_failure[i]:
            plt.plot(x,Narratives[i])
        else:
            Int_Prob_failures = [int(x) for x in Prob_failure[i] ]
            markers_on = Int_Prob_failures
            plt.plot(x,Narratives[i],'-gD', markevery=markers_on)
    plt.xlim(0,len(Narratives[0]))
    plt.ylim(0.0, 2000.0)
    plt.grid(True)
    plt.xlabel('Length of the Data Narrative', fontsize=15)
    plt.ylabel('Intervals', fontsize=15)
    plt.title('Plotting Data Narratives', weight='bold')
    plt.legend()
    plt.show()

Data = [[40.495959999999997, 68.728006916094003, 80.991919999999993, 121.48787999999999, 161.98383999999999, 200.75514611468412, 202.47979999999998, 208.8702579527606, 242.97575999999998, 426.66599412223769, 598.13431735234519, 947.40769717700846], [40.495959999999997, 80.991919999999993, 121.48787999999999, 161.98383999999999, 202.47979999999998, 209.4165446035731, 242.97575999999998, 383.51736697098818, 451.56755438353258, 503.98594436505164, 516.26217431475163, 1099.3652534435903]]
Failures = [[68.728006916094003], []]
Draw(Data,Failures)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-16 18:44:48

而不是:

代码语言:javascript
复制
Int_Prob_failures = [int(x) for x in Prob_failure[i] ]
markers_on = Int_Prob_failures
plt.plot(x,Narratives[i],'-gD', markevery=markers_on)

你可以尝试:

代码语言:javascript
复制
index = []
for j in range(len(Prob_failure[i])):
    for k in range(len(Narratives[i])):
        if Prob_failure[i][j] == Narratives[i][k]:
            index.append(k)
plt.plot(x,Narratives[i],'-gD', markevery = index )

市场期权采用你想要强调的点的指数。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43439912

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档