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

Skip to content

Commit 45b6acd

Browse files
Whats new for prop_cycle rcparam
1 parent 0065bfc commit 45b6acd

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
@@ -847,9 +847,8 @@ def _eval_cycler_expr(node):
847847
if isinstance(node, ast.Call):
848848
if not (isinstance(node.func, ast.Name) and node.func.id == 'cycler'):
849849
raise ValueError("only the 'cycler()' function is allowed")
850-
args = [ast.literal_eval(ast.unparse(a)) for a in node.args]
851-
kwargs = {kw.arg: ast.literal_eval(ast.unparse(kw.value))
852-
for kw in node.keywords}
850+
args = [ast.literal_eval(a) for a in node.args]
851+
kwargs = {kw.arg: ast.literal_eval(kw.value) for kw in node.keywords}
853852
return cycler(*args, **kwargs)
854853
raise ValueError(
855854
f"Unsupported expression in cycler string: {ast.dump(node)}")

0 commit comments

Comments
 (0)