Title: [Bug]: Markers can be integers, but numpy integers fail · Issue #30836 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Markers can be integers, but numpy integers fail · Issue #30836 · matplotlib/matplotlib
X Title: [Bug]: Markers can be integers, but numpy integers fail · Issue #30836 · matplotlib/matplotlib
Description: Bug summary There are workflows where a sequence of markers could end up in a numpy array or a pandas series. If that sequence contains only integers, the marker values will become of type np.int64. It is therefore reasonable to expect t...
Open Graph Description: Bug summary There are workflows where a sequence of markers could end up in a numpy array or a pandas series. If that sequence contains only integers, the marker values will become of type np.int64...
X Description: Bug summary There are workflows where a sequence of markers could end up in a numpy array or a pandas series. If that sequence contains only integers, the marker values will become of type np.int64...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30836
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Markers can be integers, but numpy integers fail","articleBody":"### Bug summary\n\nThere are workflows where a sequence of markers could end up in a numpy array or a pandas series. If that sequence contains only integers, the marker values will become of type `np.int64`. It is therefore reasonable to expect that these values, different in type but equal to those in the input sequence, not lead to an error.\n\n### Code for reproduction\n\n```Python\nimport matplotlib.pyplot as plt\nfrom matplotlib.markers import MarkerStyle\n\ncaretleft1 = [4][0]\ncaretleft2 = np.array([4])[0]\n\nassert caretleft1 in MarkerStyle.markers\nassert caretleft2 in MarkerStyle.markers\n\n# plt.plot([1, 2, 3], marker=caretleft1) # works\nplt.plot([1, 2, 3], marker=caretleft2) # fails\n```\n\n### Actual outcome\n\n```pytb\n---------------------------------------------------------------------------\nValueError Traceback (most recent call last)\nFile ~/abc/.venv/lib/python3.13/site-packages/matplotlib/markers.py:326, in MarkerStyle._set_marker(self, marker)\n 325 try:\n--\u003e 326 Path(marker)\n 327 self._marker_function = self._set_vertices\n\nFile ~/abc/.venv/lib/python3.13/site-packages/matplotlib/path.py:130, in Path.__init__(self, vertices, codes, _interpolation_steps, closed, readonly)\n 129 vertices = _to_unmasked_float_array(vertices)\n--\u003e 130 _api.check_shape((None, 2), vertices=vertices)\n 132 if codes is not None and len(vertices):\n\nFile ~/abc/.venv/lib/python3.13/site-packages/matplotlib/_api/__init__.py:162, in check_shape(shape, **kwargs)\n 160 text_shape += \",\"\n--\u003e 162 raise ValueError(\n 163 f\"{k!r} must be {len(shape)}D with shape ({text_shape}), \"\n 164 f\"but your input has shape {v.shape}\"\n 165 )\n\nValueError: 'vertices' must be 2D with shape (N, 2), but your input has shape ()\n\nThe above exception was the direct cause of the following exception:\n\nValueError Traceback (most recent call last)\nCell In[5], line 1\n----\u003e 1 plt.plot([1, 2, 3], marker=caretleft2)\n\nFile ~/abc/.venv/lib/python3.13/site-packages/matplotlib/pyplot.py:3838, in plot(scalex, scaley, data, *args, **kwargs)\n 3830 @_copy_docstring_and_deprecators(Axes.plot)\n 3831 def plot(\n 3832 *args: float | ArrayLike | str,\n (...) 3836 **kwargs,\n 3837 ) -\u003e list[Line2D]:\n-\u003e 3838 return gca().plot(\n 3839 *args,\n 3840 scalex=scalex,\n 3841 scaley=scaley,\n 3842 **({\"data\": data} if data is not None else {}),\n 3843 **kwargs,\n 3844 )\n\nFile ~/abc/.venv/lib/python3.13/site-packages/matplotlib/axes/_axes.py:1777, in Axes.plot(self, scalex, scaley, data, *args, **kwargs)\n 1534 \"\"\"\n 1535 Plot y versus x as lines and/or markers.\n 1536 \n (...) 1774 (``'green'``) or hex strings (``'#008000'``).\n 1775 \"\"\"\n 1776 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D)\n-\u003e 1777 lines = [*self._get_lines(self, *args, data=data, **kwargs)]\n 1778 for line in lines:\n 1779 self.add_line(line)\n\nFile ~/abc/.venv/lib/python3.13/site-packages/matplotlib/axes/_base.py:297, in _process_plot_var_args.__call__(self, axes, data, return_kwargs, *args, **kwargs)\n 295 this += args[0],\n 296 args = args[1:]\n--\u003e 297 yield from self._plot_args(\n 298 axes, this, kwargs, ambiguous_fmt_datakey=ambiguous_fmt_datakey,\n 299 return_kwargs=return_kwargs\n 300 )\n\nFile ~/abc/.venv/lib/python3.13/site-packages/matplotlib/axes/_base.py:546, in _process_plot_var_args._plot_args(self, axes, tup, kwargs, return_kwargs, ambiguous_fmt_datakey)\n 544 return list(result)\n 545 else:\n--\u003e 546 return [l[0] for l in result]\n\nFile ~/abc/.venv/lib/python3.13/site-packages/matplotlib/axes/_base.py:539, in \u003cgenexpr\u003e(.0)\n 534 else:\n 535 raise ValueError(\n 536 f\"label must be scalar or have the same length as the input \"\n 537 f\"data, but found {len(label)} for {n_datasets} datasets.\")\n--\u003e 539 result = (make_artist(axes, x[:, j % ncx], y[:, j % ncy], kw,\n 540 {**kwargs, 'label': label})\n 541 for j, label in enumerate(labels))\n 543 if return_kwargs:\n 544 return list(result)\n\nFile ~/abc/.venv/lib/python3.13/site-packages/matplotlib/axes/_base.py:338, in _process_plot_var_args._make_line(self, axes, x, y, kw, kwargs)\n 336 kw = {**kw, **kwargs} # Don't modify the original kw.\n 337 self._setdefaults(self._getdefaults(kw), kw)\n--\u003e 338 seg = mlines.Line2D(x, y, **kw)\n 339 return seg, kw\n\nFile ~/abc/.venv/lib/python3.13/site-packages/matplotlib/lines.py:394, in Line2D.__init__(self, xdata, ydata, linewidth, linestyle, color, gapcolor, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor, markerfacecoloralt, fillstyle, antialiased, dash_capstyle, solid_capstyle, dash_joinstyle, solid_joinstyle, pickradius, drawstyle, markevery, **kwargs)\n 392 marker = 'none' # Default.\n 393 if not isinstance(marker, MarkerStyle):\n--\u003e 394 self._marker = MarkerStyle(marker, fillstyle)\n 395 else:\n 396 self._marker = marker\n\nFile ~/abc/.venv/lib/python3.13/site-packages/matplotlib/markers.py:248, in MarkerStyle.__init__(self, marker, fillstyle, transform, capstyle, joinstyle)\n 246 self._user_joinstyle = JoinStyle(joinstyle) if joinstyle is not None else None\n 247 self._set_fillstyle(fillstyle)\n--\u003e 248 self._set_marker(marker)\n\nFile ~/abc/.venv/lib/python3.13/site-packages/matplotlib/markers.py:329, in MarkerStyle._set_marker(self, marker)\n 327 self._marker_function = self._set_vertices\n 328 except ValueError as err:\n--\u003e 329 raise ValueError(\n 330 f'Unrecognized marker style {marker!r}') from err\n 332 if not isinstance(marker, MarkerStyle):\n 333 self._marker = marker\n\nValueError: Unrecognized marker style np.int64(4)\n```\n\n### Expected outcome\n\n\u003cimg width=\"640\" height=\"480\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/54573c9e-6b6b-4651-a0a6-88213c399cdc\" /\u003e\n\n### Additional information\n\nI will submit a PR.\n\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n import matplotlib; print(matplotlib.__version__) 3.10.3\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n_No response_\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nNone","author":{"url":"https://github.com/has2k1","@type":"Person","name":"has2k1"},"datePublished":"2025-12-11T13:20:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/30836/matplotlib/issues/30836"}
| 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:5e2ae7c7-2ab6-2e10-3cea-28f5f8d1e9a1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A778:16A191:114A8A3:17850F0:6A52124B |
| html-safe-nonce | 610ef4a051310156d518aae56f7464a501a770f10afb3fcb491a3203c45564b9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzc4OjE2QTE5MToxMTRBOEEzOjE3ODUwRjA6NkE1MjEyNEIiLCJ2aXNpdG9yX2lkIjoiMTQ2NDc1NzEyMTU4NTM4NjA1OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c2d8d1e77a915721ac7a579d477828d1e4031653ccef8b9d7f7901ed7d23a75e |
| hovercard-subject-tag | issue:3719382401 |
| 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/30836/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e80345ffab0a881ffedd92e97e9c95df2f2df5ec7c5ca14466051584d42d48f4/matplotlib/matplotlib/issues/30836 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e80345ffab0a881ffedd92e97e9c95df2f2df5ec7c5ca14466051584d42d48f4/matplotlib/matplotlib/issues/30836 |
| og:image:alt | Bug summary There are workflows where a sequence of markers could end up in a numpy array or a pandas series. If that sequence contains only integers, the marker values will become of type np.int64... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | has2k1 |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width