Get matplotlib color cycle state

后端 未结 9 1585
慢半拍i
慢半拍i 2020-11-27 10:36

Is it possible to query the current state of the matplotlib color cycle? In other words is there a function get_cycle_state that will behave in the following wa

9条回答
  •  萌比男神i
    2020-11-27 11:05

    Note: In the latest versions of matplotlib (>= 1.5) _get_lines has changed. You now need to use next(ax._get_lines.prop_cycler)['color'] in Python 2 or 3 (or ax._get_lines.prop_cycler.next()['color'] in Python 2) to get the next color from the color cycle.

    Wherever possible use the more direct approach shown in the lower part of @joe-kington's answer. As _get_lines is not API-facing it might change again in a not backward compatible manner in the future.

提交回复
热议问题