How do I plot in real-time in a while loop using matplotlib?

Here’s the working version of the code in question (requires at least version Matplotlib 1.1.0 from 2011-11-14): import numpy as np import matplotlib.pyplot as plt plt.axis([0, 10, 0, 1]) for i in range(10): y = np.random.random() plt.scatter(i, y) plt.pause(0.05) plt.show() Note the call to plt.pause(0.05), which both draws the new data and runs the GUI’s … Read more

Which is faster: while(1) or while(2)?

Both loops are infinite, but we can see which one takes more instructions/resources per iteration. Using gcc, I compiled the two following programs to assembly at varying levels of optimization: int main(void) { while(1) {} return 0; } int main(void) { while(2) {} return 0; } Even with no optimizations (-O0), the generated assembly was … Read more

techhipbettruvabetnorabahisbahis forumu