4

I would like to know how I can generate the marker for the black colored line shown in this picture. (Source: NCEP & NOAA) It's the marker for a storm or hurricane in standard weather maps.

enter image description here

I can probably generate an image file of the marker symbol. But, I am not aware of how I can tell matplotlib to use the image as a marker.

1 Answer 1

7

The marker looks like a 6. If this is the case, you can use a 6 as a marker as follows:

import matplotlib.pyplot as plt

x = [1,2,3,4]
y = [2,3,1,4]

plt.scatter(x,y, s= 100,marker="$6$")

plt.show()

enter image description here

If this is not an option, you may define your custom marker using a path. To this end, the coordinates of the path need to be known. I have invented some values below, maybe they already suit the needs here.

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.path as mpath

def get_hurricane():
    u = np.array([  [2.444,7.553],
                    [0.513,7.046],
                    [-1.243,5.433],
                    [-2.353,2.975],
                    [-2.578,0.092],
                    [-2.075,-1.795],
                    [-0.336,-2.870],
                    [2.609,-2.016]  ])
    u[:,0] -= 0.098
    codes = [1] + [2]*(len(u)-2) + [2] 
    u = np.append(u, -u[::-1], axis=0)
    codes += codes

    return mpath.Path(3*u, codes, closed=False)

hurricane = get_hurricane()
plt.scatter([1,1,2],[1.4,2.3,2.8], s=350, marker=hurricane, 
            edgecolors="crimson", facecolors='none', linewidth=2)
plt.scatter([0,1,2],[1,3,1], s=150, marker=hurricane, 
            edgecolors="k", facecolors='none')
plt.scatter([0,1.8,3],[0,2,4], s=150, marker="o", 
            edgecolors="k", facecolors='none')

plt.show()

enter image description here

Sign up to request clarification or add additional context in comments.

8 Comments

The marker is used to denote a hurricane. It is a specific symbol. I doubt the symbol suggested works.
Where can we find information about that symbol? If you want help creating a marker you must somehow define how that marker needs to look.
Sorry about that. The 2nd and 3rd symbol in this image is what I would like to arrive at.
Thank you for the solution. I would be glad if you could explain how you arrived at the symbol. Also, what you have done is for a tropical storm. For a tropical cyclone, the circular region inside the tropical storm symbol needs to be filled. Is that possible as well?
I invented some points to define a half-spiral. Then moved that half spiral, such that its mirror point is the origin (move by 0.098 in xdirection). A path in matplotlib consists of two parts the coordinates and the codes. A code of 1 means "move to" and a code of 2 means "line to". The factor 3 in the coordinates is to make the symbol the same size as a round marker. Of course you can directly hardcode the value 0.098 and the factor 3 into the coordinates if you want.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.