|

2026/08/24 改修追記
Windows Python 3.14.6 (matplotlib 3.11.1) では、下記のようなエラーがあり、実行できない。
Traceback (most recent call last):
File "D:___\scatter_star_poly.py", line 17, in
plt.scatter(x, y, s=80, c=z, marker=(verts, 0))
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:___\AppData\Local\Python\pythoncore-3.14-64\
Lib\site-packages\matplotlib\_api\deprecation.py", line 477, in wrapper
return func(*args, **kwargs)
File "C:___\AppData\Local\Python\pythoncore-3.14-64\
Lib\site-packages\matplotlib\pyplot.py", line 4128, in scatter
__ret = gca().scatter(
x,
...<14 lines>...
**kwargs,
)
File "C:___\AppData\Local\Python\pythoncore-3.14-64\
Lib\site-packages\matplotlib\_api\deprecation.py", line 477, in wrapper
return func(*args, **kwargs)
File "C:___\AppData\Local\Python\pythoncore-3.14-64\
Lib\site-packages\matplotlib\__init__.py", line 1528, in inner
return func(
ax,
*map(cbook.sanitize_sequence, args),
**{k: cbook.sanitize_sequence(v) for k, v in kwargs.items()})
File "C:___\AppData\Local\Python\pythoncore-3.14-64\
Lib\site-packages\matplotlib\axes\_axes.py", line 5373, in scatter
marker_obj = mmarkers.MarkerStyle(marker)
File "C:___\AppData\Local\Python\pythoncore-3.14-64\
Lib\site-packages\matplotlib\markers.py", line 248, in __init__
self._set_marker(marker)
~~~~~~~~~~~~~~~~^^^^^^^^
File "C:___\AppData\Local\Python\pythoncore-3.14-64\
Lib\site-packages\matplotlib\markers.py", line 311, in _set_marker
elif isinstance(marker, Hashable) and marker in self.markers:
^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot use 'tuple' as a dict key (unhashable type: 'list')
Linux Python3 3.8.6 (matplotlib 3.3.3) では、下記のようなエラーがあり、実行できない。
Traceback (most recent call last):
File "scatter_star_poly.py", line 17, in
plt.scatter(x, y, s=80, c=z, marker=(verts, 0))
File "~/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2895, in scatter
**({"data": data} if data is not None else {}), **kwargs)
File "~/.local/lib/python3.6/site-packages/matplotlib/__init__.py", line 1447, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "~/.local/lib/python3.6/site-packages/matplotlib/cbook/deprecation.py", line 411, in wrapper
return func(*inner_args, **inner_kwargs)
File "~/.local/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 4473, in scatter
marker_obj = mmarkers.MarkerStyle(marker)
File "~/.local/lib/python3.6/site-packages/matplotlib/markers.py", line 228, in __init__
self.set_marker(marker)
File "~/.local/lib/python3.6/site-packages/matplotlib/markers.py", line 313, in set_marker
self._recache()
File "~/.local/lib/python3.6/site-packages/matplotlib/markers.py", line 241, in _recache
self._marker_function()
File "~/.local/lib/python3.6/site-packages/matplotlib/markers.py", line 372, in _set_tuple_marker
self._path = Path.unit_regular_polygon(numsides)
File "~/.local/lib/python3.6/site-packages/matplotlib/path.py", line 713, in unit_regular_polygon
if numVertices <= 16:
TypeError: '<=' not supported between instances of 'list' and 'int'
Python 3.11.2 見直しました。上記のコードでは、下記のエラーが発生します。
Traceback (most recent call last):
File "_:\scatter_star_poly.py", line 17, in <module>
plt.scatter(x, y, s=80, c=z, marker=(verts, 0))
File "C:\Users\_____\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\pyplot.py", line 2862, in scatter
__ret = gca().scatter(
^^^^^^^^^^^^^^
File "C:\Users\_____\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\__init__.py", line 1459, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\_____\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\axes\_axes.py", line 4629, in scatter
marker_obj = mmarkers.MarkerStyle(marker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\_____\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\markers.py", line 272, in __init__
self._set_marker(marker)
File "C:\Users\_____\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\markers.py", line 367, in _set_marker
self._recache()
File "C:\Users\_____\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\markers.py", line 291, in _recache
self._marker_function()
File "C:\Users\_____\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\markers.py", line 504, in _set_tuple_marker
self._path = Path.unit_regular_polygon(numsides)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\_____\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\path.py", line 749, in unit_regular_polygon
if numVertices <= 16:
^^^^^^^^^^^^^^^^^
TypeError: '<:=' not supported between instances of 'list' and 'int'
matplotlib 内部のエラーのようです。matplotlib の改修(先祖帰りバグの改修)を待つしかない。
Python 3.11.6 (matplotlib 3.7.1) では、下記のようなエラーがあり、実行できない。
Traceback (most recent call last):
File "M:\______\scatter_star_poly.py", line 17, in
plt.scatter(x, y, s=80, c=z, marker=(verts, 0))
File "C:\Users\______\AppData\Local\Programs\Python\Python311\Lib
\site-packages\matplotlib\pyplot.py", line 2862, in scatter
__ret = gca().scatter(
^^^^^^^^^^^^^^
File "C:\Users\______\AppData\Local\Programs\Python\Python311\Lib
\site-packages\matplotlib\__init__.py", line 1459, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\______\AppData\Local\Programs\Python\Python311\Lib
\site-packages\matplotlib\axes\_axes.py", line 4629, in scatter
marker_obj = mmarkers.MarkerStyle(marker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\______\AppData\Local\Programs\Python\Python311\Lib
\site-packages\matplotlib\markers.py", line 272, in __init__
self._set_marker(marker)
File "C:\Users\______\AppData\Local\Programs\Python\Python311\Lib
\site-packages\matplotlib\markers.py", line 367, in _set_marker
self._recache()
File "C:\Users\______\AppData\Local\Programs\Python\Python311\Lib
\site-packages\matplotlib\markers.py", line 291, in _recache
self._marker_function()
File "C:\Users\______\AppData\Local\Programs\Python\Python311\Lib
\site-packages\matplotlib\markers.py", line 504, in _set_tuple_marker
self._path = Path.unit_regular_polygon(numsides)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\______\AppData\Local\Programs\Python\Python311\Lib
\site-packages\matplotlib\path.py", line 749, in unit_regular_polygon
if numVertices <= 16:
^^^^^^^^^^^^^^^^^
TypeError: '<=' not supported between instances of 'list' and 'int'
Python 3.12.0 (matplotlib 3.8.1) では、下記のようなエラーがあり、実行できない。
Traceback (most recent call last):
File "E:\______\scatter_star_poly.py", line 17, in
plt.scatter(x, y, s=80, c=z, marker=(verts, 0))
File "C:\Program Files\Python312\Lib\site-packages\matplotlib\pyplot.py",
line 3687, in scatter
__ret = gca().scatter(
^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\matplotlib\__init__.py",
line 1478, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\matplotlib\axes\_axes.py",
line 4697, in scatter
marker_obj = mmarkers.MarkerStyle(marker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\matplotlib\markers.py",
line 255, in __init__
self._set_marker(marker)
File "C:\Program Files\Python312\Lib\site-packages\matplotlib\markers.py",
line 343, in _set_marker
self._recache()
File "C:\Program Files\Python312\Lib\site-packages\matplotlib\markers.py",
line 271, in _recache
self._marker_function()
File "C:\Program Files\Python312\Lib\site-packages\matplotlib\markers.py",
line 480, in _set_tuple_marker
self._path = Path.unit_regular_polygon(numsides)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\matplotlib\path.py",
line 753, in unit_regular_polygon
if numVertices <= 16:
^^^^^^^^^^^^^^^^^
TypeError: '<=' not supported between instances of 'list' and 'int'
Python 3.11.6 (matplotlib 3.7.1) 及び Python 3.12.0 (matplotlib 3.8.1) で、見直し中、新しいサンプル(lines-bars-and-markers-scatter-star-poly-py) を見つけ、下記のコードで、正常に実行できました。
"""
===============
Marker examples
===============
Example with different ways to specify markers.
See also the `matplotlib.markers` documentation for a list of all markers and
:doc:`/gallery/lines_bars_and_markers/marker_reference` for more information
on configuring markers.
.. redirect-from:: /gallery/lines_bars_and_markers/scatter_custom_symbol
.. redirect-from:: /gallery/lines_bars_and_markers/scatter_symbol
.. redirect-from:: /gallery/lines_bars_and_markers/scatter_piecharts
"""
import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
np.random.seed(19680801)
x = np.random.rand(10)
y = np.random.rand(10)
z = np.sqrt(x**2 + y**2)
fig, axs = plt.subplots(2, 3, sharex=True, sharey=True, layout="constrained")
# Matplotlib marker symbol
axs[0, 0].scatter(x, y, s=80, c=z, marker=">")
axs[0, 0].set_title("marker='>'")
# marker from TeX: passing a TeX symbol name enclosed in $-signs
axs[0, 1].scatter(x, y, s=80, c=z, marker=r"$\clubsuit$")
axs[0, 1].set_title(r"marker=r'\$\clubsuit\$'")
# marker from path: passing a custom path of N vertices as a (N, 2) array-like
verts = [[-1, -1], [1, -1], [1, 1], [-1, -1]]
axs[0, 2].scatter(x, y, s=80, c=z, marker=verts)
axs[0, 2].set_title("marker=verts")
# regular pentagon marker
axs[1, 0].scatter(x, y, s=80, c=z, marker=(5, 0))
axs[1, 0].set_title("marker=(5, 0)")
# regular 5-pointed star marker
axs[1, 1].scatter(x, y, s=80, c=z, marker=(5, 1))
axs[1, 1].set_title("marker=(5, 1)")
# regular 5-pointed asterisk marker
axs[1, 2].scatter(x, y, s=80, c=z, marker=(5, 2))
axs[1, 2].set_title("marker=(5, 2)")
plt.show()
Python 3.11.6 (matplotlib 3.7.1) 及び Python 3.12.0 (matplotlib 3.8.1) 共に、正常実行です。

Windows Python 3.14.6 (matplotlib 3.11.1) では、正常に、実行できる。
Linux Python3 3.8.6 (matplotlib 3.3.3) では、下記のようなエラーがあり、実行できない。
Traceback (most recent call last):
File "scatter_star_poly_2.py", line 26, in
fig, axs = plt.subplots(2, 3, sharex=True, sharey=True, layout="constrained")
File "~/.local/lib/python3.6/site-packages/matplotlib/cbook/deprecation.py", line 451, in wrapper
return func(*args, **kwargs)
File "~/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 1287, in subplots
fig = figure(**fig_kw)
File "~/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 693, in figure
**kwargs)
File "~/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 315, in new_figure_manager
return _backend_mod.new_figure_manager(*args, **kwargs)
File "~/.local/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 3493, in new_figure_manager
fig = fig_cls(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'layout'
|