Hello everyone!
I have a pandas dataframe called “data” having 5 columns: station,latitude,longitude,avg_beta,num_triggered
I want to plot the stations (triangles) using two groups of colors. The first color palette resulting from the 4th column (i.e. avg_beta that are float) fills the inside of the triangle and the second palette sets the border of triangles (i.e. num_triggered that is integer values).
I first plotted stations just filling their inside with black “pen” attribute for all stations which is this:
pygmt.makecpt(
cmap = beta_cmap,
series = f'{data.avg_beta.min()}/{data.avg_beta.max()}/1',
continuous = True,
reverse = 'z'
)
fig.plot(
x = data.longitude,
y = data.latitude,
size = [0.8]*len(data.avg_beta),
color = data.avg_beta,
cmap = True,
style = "t",
pen = "black",
)
fig.colorbar(
box = False,
frame = ['a1','x+l"all beta average"'],
scale = 1,
)
This gives me the following map:
Now, I want each triangle to have a different color for the “pen” attribute. I used the zip function in a for loop but it didn’t give me the desired result. The unsuccessful try is this (p.s.: I was not able to plot this so add the colors as a list for the pen attribute, any idea how to use a cpt pallete for this?):
colors = ["black", "blue","red","green", "yellow", "red", "white","black", "blue","red","green", "yellow", "red", "white","black", "blue","red","green", "yellow", "red", "white","black", "blue","red","green", "yellow", "red", "white", "red", "red"]
x, y , fills = data.longitude, data.latitude, data.avg_beta
for lon, lat, color, fill in zip(x, y, colors, fills):
fig.plot(
x = lon,
y = lat,
cmap = True,
style = "t0.7c",
pen = color,
fill = fill,
)
This gives the border of the triagnle in color but not the fill color.
Could you please help me with this? I really appreciate your time.