Skip to content
Advertisement

Seaborn scatter plot from pandas dataframe colours based on third column

I have a pandas dataframe, with columns ‘groupname’, ‘result’, and ‘temperature’. I’ve plotted a Seaborn swarmplot, where x=’groupname’ and y=’result’, which shows the results data separated into the groups.

What I also want to do is to colour the markers according to their temperature, using a colormap, so that for example the coldest are blue and hottest red.

Plotting the chart is very simple:

JavaScript

But now I’m stuck trying to colour the points, I’ve tried a few things like:

JavaScript

which doesn’t seem to do anything.

Also tried:

JavaScript

which does colour the points depending on the temperature, however the colours are random rather than mapped.

I feel like there is probably a very simple way to do this, but haven’t been able to find any examples.

Ideally looking for something like:

JavaScript

Advertisement

Answer

Hello the keyword you are looking for is “palette”

Below should work:

JavaScript

http://man.hubwiz.com/docset/Seaborn.docset/Contents/Resources/Documents/generated/seaborn.stripplot.html

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement