fix set_color_cycle from matplotlib deprecation warning
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 21 Apr 2016 19:14:28 +0300
changeset 1497 7330c85534ea
parent 1496 ac8a90b278f1
child 1498 b11045a2f17c
fix set_color_cycle from matplotlib deprecation warning

/usr/lib/python2.7/dist-packages/matplotlib/cbook.py:137: MatplotlibDeprecationWarning: The set_color_cycle attribute was deprecated in version 1.5. Use set_prop_cycle instead.
warnings.warn(message, mplDeprecation, stacklevel=1)
controls/DebugVariablePanel/DebugVariableGraphicViewer.py
--- a/controls/DebugVariablePanel/DebugVariableGraphicViewer.py	Thu Apr 21 17:51:29 2016 +0300
+++ b/controls/DebugVariablePanel/DebugVariableGraphicViewer.py	Thu Apr 21 19:14:28 2016 +0300
@@ -41,6 +41,12 @@
 from DebugVariableViewer import *
 from GraphButton import GraphButton
 
+
+from distutils.version import LooseVersion
+if LooseVersion(matplotlib.__version__) >= LooseVersion("1.5.0"):
+    from cycler import cycler
+
+
 # Graph variable display type
 GRAPH_PARALLEL, GRAPH_ORTHOGONAL = range(2)
 
@@ -975,7 +981,13 @@
             kwargs["transform"] = self.Axes.transAxes
             return text_func(*args, **kwargs)
         return AddText
-    
+
+    def SetAxesColor(self, color):
+        if LooseVersion(matplotlib.__version__) >= LooseVersion("1.5.0"):
+            self.Axes.set_prop_cycle(cycler('color',color))
+        else:
+            self.Axes.set_color_cycle(color)
+        
     def ResetGraphics(self):
         """
         Reset figure and graphical elements displayed in it
@@ -987,7 +999,7 @@
         # Add 3D projection if graph is in 3D
         if self.Is3DCanvas():
             self.Axes = self.Figure.gca(projection='3d')
-            self.Axes.set_color_cycle(['b'])
+            self.SetAxesColor(['b'])
             
             # Override function to prevent too much refresh when graph is 
             # rotated
@@ -1002,7 +1014,7 @@
         
         else:
             self.Axes = self.Figure.gca()
-            self.Axes.set_color_cycle(COLOR_CYCLE)
+            self.SetAxesColor(COLOR_CYCLE)
         
         # Set size of X and Y axis labels
         self.Axes.tick_params(axis='x', labelsize='small')