Skip to content
Advertisement

Highlight specific sample in stripplot from pandas dataframe

I have a pandas dataframe as the following (although with more rows and columns):

Index LOC1 LOC2 LOC 3
A 0.054 1.2 0.00
B 0.38 3.89 0.027
C 3.07 2.67 1.635
D 7.36 6.2 0.23

I was wondering if it’s possible to highlight stripplot dots that belong to a specific sample. In my dataframe samples are index names (‘A’, ‘B’…). So, for example, I would like to use a different color for values in the ‘C’ row. As I pass my dataset in a wide-form https://seaborn.pydata.org/generated/seaborn.stripplot.html , I guess I can’t use hue, but I wasn’t able to figure out any other way.

JavaScript

Advertisement

Answer

You could reshape your dataframe then use ‘hue’, assuming ‘Index’ is in the dataframe index, then you need to reset_index before melt:

JavaScript

Output:

enter image description here


JavaScript

Output:

enter image description here

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