Color coding with scatterplot graphing in matplotlib

I am working on a project for an astronomy class I have but am having trouble with doing a scatterplot with matplotlib. I am very new to python so I am struggling to find my mistake.

rscale FIRE-2

rsl = tablel['CE r_scale [kpc]']

Mstar FIRE-2

msl = tablel['M_star [M_sun]']

Plotting

for mass in msl:

if mass < 9.99e5:
    x = 'mistyrose'
    
elif mass > 9.99e5 and mass < 9.99e7:
    x = 'red'
    
elif mass > 9.99e7 and mass < 9.99e10:
    x = 'darkred'

plt.scatter(msl, rsl, c = x)

plt.xscale("log") plt.yscale("log")

I have a table of data that I am using. In this table, we have several masses in units of Msun, which are contained in a list of msl. I want to make a scatterplot of these masses compared to scale radius (rsl). However, I also want to separate them into three separate groups with different colors. When I do the code above I get the following graph:

The graph just plots all the points in a different color.

If someone could advise me in the right direction I would be very grateful! Thanks all.



from Recent Questions - Stack Overflow https://ift.tt/2RP2RAI
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation