J'ai une liste de listes composée de deux données différentes pour tracer 2 lignes et une autre liste de listes composées de marqueurs sur ces lignes respectives. mais la liste de marqueurs peut avoir un ensemble vide. J'ai écrit un code mais il n'affiche aucune image. Quelqu'un peut-il me dire pourquoi les lignes suivantes ne fonctionnent pas?Marqueurs sur la ligne
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)
Pourriez-vous ajuster votre code avec l'indentation droite ... comme c'est maintenant il est difficile de le lire – Astrom
@astrom, oops désolé. Je n'ai pas remarqué. Veuillez patienter –
@Astrom, c'est fait! merci –