是否可以获得绘图中使用的颜色列表?考虑这个例子:
line1 = ax1.plot(x1,y1)
line2 = ax1.plot(x2,y2)
Run Code Online (Sandbox Code Playgroud)
我现在如何设置颜色
plt.setp(line1,'color','red')
plt.setp(line2,'color','red')
Run Code Online (Sandbox Code Playgroud)
但有没有办法学习使用什么颜色?plt.getp(line1,'color')不起作用并抱怨
AttributeError: 'list' object has no attribute 'get_color'
Run Code Online (Sandbox Code Playgroud) 有谁知道为什么-O2打破了这段代码?我怀疑它是gcc中的一个错误,因为它可以在不同平台和不同版本的gcc上正常工作.但是,代码也可能包含一些我不知道的特性.谁能开导我?
这是代码,它是可变数量的嵌套循环的实现,产生所有可能的组合.预期的产出是
100 1
010 2
001 4
110 3
101 5
Run Code Online (Sandbox Code Playgroud)
和破碎的版本报告
100 1
010 2
001 4
100 1
010 2
Run Code Online (Sandbox Code Playgroud)
代码是:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main()
{
int nmax = 5; // finish after 5 combinations
int n = 3; // three elements
int *out = (int*) calloc(nmax, sizeof(int));
int *cnt = (int*) calloc(n, sizeof(int)); // declaring volatile solves the problem. But why ?
int il, nl, i = 0;
for (nl=1; nl<=n; nl++) …Run Code Online (Sandbox Code Playgroud)