Title: Customised dashed linstyle in matplotlib.cycler throws ValueError when using in Axes.set_prop_cycle · Issue #15825 · matplotlib/matplotlib · GitHub
Open Graph Title: Customised dashed linstyle in matplotlib.cycler throws ValueError when using in Axes.set_prop_cycle · Issue #15825 · matplotlib/matplotlib
X Title: Customised dashed linstyle in matplotlib.cycler throws ValueError when using in Axes.set_prop_cycle · Issue #15825 · matplotlib/matplotlib
Description: Bug report Bug summary Using a cycler from matplotlib with a customised dashed linestyle for the property cycle in Axes.set_prop_cycle throws a ValueError (see below). Importing cycler from cycler works as expected. Code for reproduction...
Open Graph Description: Bug report Bug summary Using a cycler from matplotlib with a customised dashed linestyle for the property cycle in Axes.set_prop_cycle throws a ValueError (see below). Importing cycler from cycler ...
X Description: Bug report Bug summary Using a cycler from matplotlib with a customised dashed linestyle for the property cycle in Axes.set_prop_cycle throws a ValueError (see below). Importing cycler from cycler ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/15825
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Customised dashed linstyle in matplotlib.cycler throws ValueError when using in Axes.set_prop_cycle","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nUsing a cycler from matplotlib with a customised dashed linestyle for the property cycle in Axes.set_prop_cycle throws a ValueError (see below). Importing cycler from cycler works as expected.\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug.\r\nPlease make sure to minimize the number of dependencies required, and provide\r\nany necessary plotted data.\r\nAvoid using threads, as Matplotlib is (explicitly) not thread-safe.--\u003e\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib import rcParams\r\nfrom matplotlib import cycler # from cycler import cycler works fine\r\n\r\ncc = cycler('linestyle', [(0,(3,1)), '-'])\r\n\r\nfig = plt.figure()\r\nax = fig.add_subplot(221)\r\nax.set_prop_cycle(cc)\r\nax.plot(range(10))\r\n\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"err.py\", line 10, in \u003cmodule\u003e\r\n ax.plot(range(10))\r\n File \"/usr/local/lib/python3.7/site-packages/matplotlib/axes/_axes.py\", line 1665, in plot\r\n lines = [*self._get_lines(*args, data=data, **kwargs)]\r\n File \"/usr/local/lib/python3.7/site-packages/matplotlib/axes/_base.py\", line 225, in __call__\r\n yield from self._plot_args(this, kwargs)\r\n File \"/usr/local/lib/python3.7/site-packages/matplotlib/axes/_base.py\", line 405, in _plot_args\r\n seg = func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)\r\n File \"/usr/local/lib/python3.7/site-packages/matplotlib/axes/_base.py\", line 312, in _makeline\r\n seg = mlines.Line2D(x, y, **kw)\r\n File \"/usr/local/lib/python3.7/site-packages/matplotlib/lines.py\", line 377, in __init__\r\n self.set_linestyle(linestyle)\r\n File \"/usr/local/lib/python3.7/site-packages/matplotlib/lines.py\", line 1186, in set_linestyle\r\n cbook._check_in_list([*self._lineStyles, *ls_mapper_r], ls=ls)\r\n File \"/usr/local/lib/python3.7/site-packages/matplotlib/cbook/__init__.py\", line 2170, in _check_in_list\r\n .format(v, k, ', '.join(map(repr, values))))\r\nValueError: '(0, (3, 1))' is not a valid value for ls; supported values are '-', '--', '-.', ':', 'None', ' ', '', 'solid', 'dashed', 'dashdot', 'dotted'\r\n```\r\n\r\n**Expected outcome**\r\n\r\nI would expect matplotlib.cycler to work the same as cycler.cycler. However, in this case matplotlib.cycler throws a ValueError.\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: macOS Mojave 10.14.6\r\n * Matplotlib version: 3.1.2\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): MacOSX\r\n * Python version: 3.7.4\r\n * Jupyter version (if applicable): --\r\n * Other libraries: --\r\n\r\nmatplotlib installed via pip\r\n","author":{"url":"https://github.com/sdschmidt","@type":"Person","name":"sdschmidt"},"datePublished":"2019-12-03T22:29:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/15825/matplotlib/issues/15825"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a1423aee-a02b-b273-e1fd-221057a25b0d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D6CA:2C65A3:33F4789:46B14A3:6A53EBC7 |
| html-safe-nonce | 5b10063095786528a0a8c7c541205f1d718a82df46a30da915398f497c4798b7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkNBOjJDNjVBMzozM0Y0Nzg5OjQ2QjE0QTM6NkE1M0VCQzciLCJ2aXNpdG9yX2lkIjoiNDA4NzUxOTk5OTQyOTk2MjY5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6514d366c98e9f091c9528e5f871e6808e8d52d19cd4ff1dcfeacd646ee88154 |
| hovercard-subject-tag | issue:532310046 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/15825/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fdd908bccb93e03ce11733aad10e9ad9b4484af7f557e6cd942e48c516f99347/matplotlib/matplotlib/issues/15825 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fdd908bccb93e03ce11733aad10e9ad9b4484af7f557e6cd942e48c516f99347/matplotlib/matplotlib/issues/15825 |
| og:image:alt | Bug report Bug summary Using a cycler from matplotlib with a customised dashed linestyle for the property cycle in Axes.set_prop_cycle throws a ValueError (see below). Importing cycler from cycler ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sdschmidt |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width