मैं नीचे दिए गए कोड से एनिमेटेड हिस्टोग्राम बनाने की कोशिश कर रहा हूं। मैं प्रत्येक बार के लिए अलग-अलग हिस्टोग्राम बना सकता हूं, हालांकि मुझे matplotlib.animation
फ़ंक्शन के साथ एनिमेटेड परिणाम नहीं मिल सकते हैं या matplotlib tutorial में कोड को अनुकरण करने से नहीं मिल सकते हैं।Matplotlib एनिमेटेड हिस्टोग्राम
import numpy as np
import matplotlib.pyplot as plt
betas = [] # some very long list
entropy = [] # some very long list
for time in [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0 , 3.5, 4.0, 4.5 5.0, 5.5, 6.0, 6.5 , 7.0, 7.5, 8.0 , 8,5 , 9.0, 9.5 , 10.0]:
plt.figure('entropy distribution at time %s ' % time)
indexbetas = {i for i, j in enumerate(betas) if j == time}
desiredentropies = [x for i, x in enumerate(entropy) if i in indexbetas] #the desiredentropies list depends on time
n, bins, patches = plt.hist(desiredentropies, 20, alpha=0.75 , label = 'desired entropies')
plt.xlabel(r"$S_{(\time=%d)}$" % time, fontsize=20)
plt.ylabel('Frequency of entropies')
plt.legend()
plt.grid(True)
plt.show()
मैं अपने desiredentropies
सूची जो एनीमेशन के लिए time
सूची में तत्व पर निर्भर करता है खिला के साथ विशेष रूप से संघर्ष कर रहा हूँ।
ट्यूटोरियल से उदाहरण के लिए मेरे द्वारा काम करने के लिए कुछ सेकंड की आवश्यकता है - पायथन 2.7.11 और 3.4.3/लिनक्स मिंट 17. क्या आपको कंसोल/टर्मिनल/cmd.exe में कोई त्रुटि संदेश मिलता है? – furas
@furas मैंने अपने ओपी में एक संपादन जोड़ा है। मेरी मुख्य समस्या अद्यतित वांछित सूची को खिला रही है, मैं समय परिवर्तन के रूप में एक हिस्टोग्राम बनाना चाहता हूं। नोट: वांछित सूची सूची समय में प्रत्येक तत्व के लिए बदलती है। –
आपको 'एनीमेशन। फनकएनीमेशन' – furas