0

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?

1
  • Could you post the traceback? Commented Feb 11, 2014 at 15:43

1 Answer 1

1

You are using the = symbol instead of the : symbol at the end of your dict definition. That might cause a SyntaxError.

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

Comments

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.