Reputation: 101
I am trying to plot a scatter plot using certain colours for certain data points.
data = np.genfromtxt('overallplotfile.csv',delimiter=',',dtype=str,skiprows=1)
data2 = np.genfromtxt('overallplotfile.csv',delimiter=',',dtype=float,skiprows=1)
x = data2[:,1]
y = data2[:,3]
z = data[:,2]
Column 2 (z) now contains station names which I want to later assign colours to.
scatter(x,y)
plot(x,yp)
assigns colours to the station names in z.
use_colours = {"KNZ": "red", "PXZ": "red", "BFZ": "red","MQZ": "red","OPZ": "red","TUZ": "red","PUZ": "red","TSZ": "red","WEL": "red","MRZ": "red","KHZ": "red","ODZ": "red","MLZ": "red", "VRZ": "green", "WIZ": "green", "NNZ": "green", "THZ": "green", "WVZ": "green", "WKZ": "green", "MLZ": "green","WHZ": "green", "PYZ": "green", "TOZ": "blue","TLZ": "cyan", "HIZ": "cyan","QRZ": "cyan","DSZ": "cyan", "FOZ": "cyan","JCZ": "cyan","MSZ": "cyan","DCZ": "cyan", "WAZ": "yellow", "WIZ": "yellow", "URZ": "yellow","LTZ": "yellow","RPZ": "yellow","LBZ": "yellow","EAZ": "yellow", "MXZ" = "magenta", "BKZ" = "magenta","MWZ" = "magenta", "OXZ" = "magenta", "APZ" = "magenta"}
ax.scatter(x,y,c=[use_colours[x[0]] for x in z],s=50)
Labels the data points with the station names. map(text,x,y,z)
However I am getting an invalid syntax error when I try to assign the colours to the stations. Can anyone help me?
Upvotes: 0
Views: 294
Reputation: 6227
You are using the =
symbol instead of the :
symbol at the end of your dict
definition. That might cause a SyntaxError
.
Upvotes: 1