为什么matplotlib.pyplot.xlim()方法在下面的示例中不起作用?
import matplotlib.pyplot as plt
l = [0,0.2,0.4,0.6,0.8,1.0]
plt.plot(l,l)
plt.xlim = (-10,10)
plt.show()
答案 0 :(得分:3)
matplotlib.pyplot.xlim
,matplotlib.pyplot.ylim
是函数。你应该打电话给他们,而不是分配给他们:
plt.ylim(-10,10)
plt.xlim(-10,10)
答案 1 :(得分:3)
plt.xlim((-10,10))
是一个功能。您需要通过调用相应的限制来使用它,而不是更改此功能。
for (int i = 0; i < 10000; ++i) {
queue.add(i);
}
double timer_started = omp_get_wtime();
#pragma omp parallel
{
size_t counter = 0;
Node *n;
while ((n = queue.remove()) != NULL) {
processNode(n);
counter++;
}
#pragma omp critical
std::cout << "Thread " << omp_get_thread_num() << " processed " << counter << " nodes." << std::endl;
}
void processNode(Node *node) {}