Title: plt.errorbar raises error when given marker=
Open Graph Title: plt.errorbar raises error when given marker=
X Title: plt.errorbar raises error when given marker=
Description: Bug report Bug summary plt.errorbar( ..., marker=
Open Graph Description: Bug report Bug summary plt.errorbar( ..., marker=
X Description: Bug report Bug summary plt.errorbar( ..., marker=<matplotlib.markers.MarkerStyle object>) raises a `TypeError: float() argument must be a string or a number, not 'MarkerStyle' unexpec...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/18600
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"plt.errorbar raises error when given marker=\u003cmatplotlib.markers.MarkerStyle object\u003e","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\n\u003c!--A short 1-2 sentences that succinctly describes the bug--\u003e\r\n\r\n`plt.errorbar( ..., marker=\u003cmatplotlib.markers.MarkerStyle object\u003e)` raises a `TypeError: float() argument must be a string or a number, not 'MarkerStyle' unexpectedly.\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\n#!/usr/bin/env python3\r\n\r\nimport matplotlib\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.markers import MarkerStyle\r\n\r\nprint(f\"{matplotlib.__version__=}\")\r\nprint(matplotlib.get_backend())\r\n\r\n# I want to use this marker in an errorbar plot\r\nm = MarkerStyle(\"D\")\r\nm._transform.scale(1.0, 0.6)\r\nprint(m)\r\n\r\n# I can use it in a scatter plot\r\nfig, ax = plt.subplots()\r\nplt.scatter([1,2,3],[1,2,3], s=225, marker=\"d\")\r\nplt.scatter([1,2,3],[2,3,4], s=225, marker=m, color=\"crimson\")\r\nplt.errorbar([1,2,3],[3,4,5], yerr=[0.5,0.5,0.5], marker='o', linestyle='none', color='green')\r\nplt.show()\r\n# which produces a figure similar to https://stackoverflow.com/a/49662571/\r\n\r\n# But when I use it in errorbar\r\nfix, ax = plt.subplots()\r\nplt.errorbar([1,2,3],[3,4,5], yerr=[0.5,0.5,0.5], marker=m, linestyle='none', color='green')\r\nplt.show()\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\u003c!--The output produced by the above code, which may be a screenshot, console output, etc.--\u003e\r\nThe first figure is produced with a correctly-rotated marker, similar to [this Stack Overflow answer](https://stackoverflow.com/questions/49660174/rotate-existing-matplotlib-markers/49662571#49662571), which looks like this:\r\n\r\n\r\n\r\nAfter closing the first figure, the second figure, in contrast, gives an error.\r\n\r\n```\r\n\u003e ./example.py\r\nmatplotlib.__version__='3.2.2'\r\n\u003cmatplotlib.markers.MarkerStyle object at 0x106e89d00\u003e\r\nTraceback (most recent call last):\r\n File \"./example.py\", line 25, in \u003cmodule\u003e\r\n plt.errorbar([1,2,3],[3,4,5], yerr=[0.5,0.5,0.5], marker=m, color='green')\r\n File \"/usr/local/lib/python3.8/site-packages/matplotlib/pyplot.py\", line 2524, in errorbar\r\n return gca().errorbar(\r\n File \"/usr/local/lib/python3.8/site-packages/matplotlib/__init__.py\", line 1565, in inner\r\n return func(ax, *map(sanitize_sequence, args), **kwargs)\r\n File \"/usr/local/lib/python3.8/site-packages/matplotlib/axes/_axes.py\", line 3265, in errorbar\r\n data_line = mlines.Line2D(x, y, **plot_line_style)\r\n File \"/usr/local/lib/python3.8/site-packages/matplotlib/lines.py\", line 378, in __init__\r\n self._marker = MarkerStyle(marker, fillstyle)\r\n File \"/usr/local/lib/python3.8/site-packages/matplotlib/markers.py\", line 225, in __init__\r\n self.set_marker(marker)\r\n File \"/usr/local/lib/python3.8/site-packages/matplotlib/markers.py\", line 289, in set_marker\r\n Path(marker)\r\n File \"/usr/local/lib/python3.8/site-packages/matplotlib/path.py\", line 127, in __init__\r\n vertices = _to_unmasked_float_array(vertices)\r\n File \"/usr/local/lib/python3.8/site-packages/matplotlib/cbook/__init__.py\", line 1317, in _to_unmasked_float_array\r\n return np.asarray(x, float)\r\n File \"/usr/local/lib/python3.8/site-packages/numpy/core/_asarray.py\", line 83, in asarray\r\n return array(a, dtype, copy=False, order=order)\r\nTypeError: float() argument must be a string or a number, not 'MarkerStyle'\r\n```\r\n\r\n**Expected outcome**\r\n\r\n\u003c!--A description of the expected outcome from the code snippet--\u003e\r\n\r\nThe second figure should show a sequence of diamonds that are the `thin_diamond` marker but rotated 90˚ (so that it's wider than it is tall), like the red diamonds in the first figure, but with error bars of width 0.5 (like the green circles in the first figure).\r\n\r\n\u003c!--If this used to work in an earlier version of Matplotlib, please note the version it used to work on--\u003e\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 Catalina 10.15.6\r\n * Matplotlib version: 3.2.2\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): MacOSX\r\n * Python version: 3.8.5\r\n * Jupyter version (if applicable):\r\n * Other libraries: \r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\nInstalled mpl via pip3.","author":{"url":"https://github.com/evanberkowitz","@type":"Person","name":"evanberkowitz"},"datePublished":"2020-09-28T17:35:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/18600/matplotlib/issues/18600"}
| 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:5985cc93-d6af-9216-83c4-733fb5099990 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8518:2B78D3:4BD6F3:64655B:6A52FEAF |
| html-safe-nonce | 388e608c3f8ab5e698afadcf05acc50ecf27cb144089954f262819201a966c46 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTE4OjJCNzhEMzo0QkQ2RjM6NjQ2NTVCOjZBNTJGRUFGIiwidmlzaXRvcl9pZCI6IjIxMDQ0OTYyMTk3NjYzMjQ5MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a51d1261e818637178fadc1c81cf23fb084b7ead02081f90f352f605456bf84f |
| hovercard-subject-tag | issue:710453960 |
| 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/18600/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e5fd95c84cfa99ffe36f22ef6562dca1b870ff1ecbde52635973210ae333075e/matplotlib/matplotlib/issues/18600 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e5fd95c84cfa99ffe36f22ef6562dca1b870ff1ecbde52635973210ae333075e/matplotlib/matplotlib/issues/18600 |
| og:image:alt | Bug report Bug summary plt.errorbar( ..., marker= |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | evanberkowitz |
| 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