Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5a4d76b

Browse files
scottshambaughksunden
authored andcommitted
Whats new for prop_cycle rcparam
1 parent 1406ee2 commit 5a4d76b

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
``axes.prop_cycle`` rcParam must be literal
2+
--------------------------------------------
3+
4+
The ``axes.prop_cycle`` rcParam is now parsed safely without ``eval()``. Only
5+
literal ``cycler()`` calls combined with ``+`` and ``*`` are allowed. All
6+
previously valid cycler strings continue to work, for example:
7+
8+
.. code-block:: none
9+
10+
axes.prop_cycle : cycler('color', ['r', 'g', 'b']) + cycler('linewidth', [1, 2, 3])

lib/matplotlib/rcsetup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,8 @@ def _eval_cycler_expr(node):
791791
if isinstance(node, ast.Call):
792792
if not (isinstance(node.func, ast.Name) and node.func.id == 'cycler'):
793793
raise ValueError("only the 'cycler()' function is allowed")
794-
args = [ast.literal_eval(ast.unparse(a)) for a in node.args]
795-
kwargs = {kw.arg: ast.literal_eval(ast.unparse(kw.value))
796-
for kw in node.keywords}
794+
args = [ast.literal_eval(a) for a in node.args]
795+
kwargs = {kw.arg: ast.literal_eval(kw.value) for kw in node.keywords}
797796
return cycler(*args, **kwargs)
798797
raise ValueError(
799798
f"Unsupported expression in cycler string: {ast.dump(node)}")

0 commit comments

Comments
 (0)