Python相当于Matlab中的get(,'color')函数

时间:2016-08-08 18:15:54

标签: python plot

我是Python的新手。请原谅我的假问题。我想实现一些非常类似于以下Matlab代码的东西,但我坚持使用它的Python等价物:

...
Subplot (2,1,1);
H = plot (rand(100,5));
C = get (H, 'Color')
H = area (myX, myY);
H(1).FaceColor = C1;
H(2).FaceColor = C2;
Grid on;
...

有人可以给我一些灯吗?非常感谢!

1 个答案:

答案 0 :(得分:1)

查看matplotlib进行绘图。然后,您可以将get_color()用于行对象。

这是一个最小的例子:

import numpy as np
import matplotlib.pyplot as plt
a=np.random.random((100,5))
fig, ax = plt.subplots()

lines=ax.plot(a)

#line_colors is a list of colors used for the lines in this plot. they are in string format, i.e. 'b' for blue etc.
line_colors=[l.get_color() for l in lines]