0

I'm trying to add weather markers instead of basic circles in a scatterplot. More specifically, I'd like to show physical and mental changes depending on weather conditions. For this purpose, I'd like to use some weather icons (.svg files) instead of differently colored circles. However, I obtain the following error:

TypeError: unhashable type: 'Path'

Here's my code:

clear_marker = parse_path("""M 350.04,161.95
           C 350.04,161.95 391.76,120.24 391.76,120.24M 120.24,391.76
           C 120.24,391.76 161.96,350.04 161.96,350.04M 389.00,256.00
           C 389.00,256.00 448.00,256.00 448.00,256.00M 64.00,256.00
           C 64.00,256.00 123.00,256.00 123.00,256.00M 350.04,350.04
           C 350.04,350.04 391.76,391.76 391.76,391.76M 120.24,120.24
           C 120.24,120.24 161.96,161.95 161.96,161.95M 256.00,389.00
           C 256.00,389.00 256.00,447.99 256.00,447.99M 256.00,64.00
           C 256.00,64.00 256.00,123.00 256.00,123.00M 157.56,216.68M 150.90,242.12
           C 150.31,246.60 150.00,251.26 150.00,256.00
             150.00,256.01 150.00,256.02 150.00,256.02
             150.00,314.57 197.46,362.02 256.00,362.02
             314.54,362.02 362.00,314.57 362.00,256.02
             362.00,197.48 314.54,150.02 256.00,150.02
             220.35,150.02 188.80,167.63 169.59,194.62M 276.00,170.00
           C 217.46,170.00 170.01,217.46 170.01,276.00
             170.01,300.17 178.09,322.45 191.71,340.28
             209.54,353.90 231.82,361.99 255.99,361.99
             314.53,361.99 361.99,314.53 361.99,255.99
             361.99,231.83 353.90,209.55 340.29,191.72
             322.52,178.10 300.28,170.00 276.16,170.00
             276.11,170.00 276.05,170.00 276.00,170.00
             276.00,170.00 276.00,170.00 276.00,170.00 Z""")
plt.plot(x, y, 'o', marker = clear_marker)

(I only tried on the first marker to see if it worked)

THANKS.

Somnus
  • 13
  • 4
  • See [Matplotlib custom marker/symbol](https://stackoverflow.com/a/58552620/12046409) – JohanC Dec 02 '21 at 13:06
  • Which matplotlib version are you using? I tried this with version 3.4.3, leaving out the `'o'` and adding `ls=''`. So, `plt.plot(x, y, ls='', marker=clear_marker)`, producing star-shaped markers. Note that it might help to subtract the mean to nicely center the marker: `clear_marker.vertices -= clear_marker.vertices.mean(axis=0)` – JohanC Dec 02 '21 at 13:08
  • I'm using matplotlib 3.4.3. I did the same but still "unhashable type: Path". Also I'm using svg.path 4.1 (function parse_path). – Somnus Dec 02 '21 at 13:13
  • The linked post uses `!pip install svgpath2mpl matplotlib` and `from svgpath2mpl import parse_path`. version `1.0.0` – JohanC Dec 02 '21 at 13:31
  • `svg.path` doesn't seem to create matplotlib paths. You need `svgpath2mpl ` – JohanC Dec 02 '21 at 14:02

0 Answers0