开发者

matplotlib: is a changing background color possible?

matplotlib python: How do you change the background color of a line plot according to a given column? Say I have the following data file

1. 0
4. 0
2. 0
1. 1
2. 1
3. 1
3. 2
1. 2
2. 2

The first column represents the y-values, and the 2nd column should control the backgroun开发者_运维百科d color. Say, it plots the (black) line on a white-gray alternating background (zebra-like) as proceeding further in x-direction, where the transition in color occurs anytime the integer in the 2nd column increments. Or other possible solution: Use 2nd column as function argument to determine background color.

How would one do this with matlibplot?


This one works:

    plt.axvspan(x, x2, facecolor='g', alpha=0.5)

where facecolor is the foreground color

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜