1

This is my Table:

this is my data

I can customize a column like so:

cm = sns.light_palette("green", as_cmap=True)
col1 = col1.dropna()
col1.style.background_gradient(cmap=cm)

which results in:

enter image description here

  1. I would like to color the cells according to their value, for example: In the Green value column, the RED and BLUE (RGB) values are 0 and I would like to have it colored according to the color scale of green (as well for the Hue column from the HSV scale). Is there a way to do it?

  2. Do you have any recommendation on which scale to use in order to visualize a temperature column?

Thanks a lot!

blackraven
  • 5,284
  • 7
  • 19
  • 45
HavingNoHead
  • 117
  • 1
  • 8
  • See [my answer](https://stackoverflow.com/a/10902473/355230) to the question [Range values to pseudocolor](https://stackoverflow.com/questions/10901085/range-values-to-pseudocolor). – martineau May 21 '22 at 16:14

1 Answers1

1
import pandas as pd
df = pd.DataFrame({'Hue value': [66.7, 0.42, 335.7, 77.9],
                   'Green value': [41.6, 4.23, 147.7, 37.3],
                   'Temperature': [39.9, 28.1, 41.8, 29.8]
                   })
print(df)

   Hue value  Green value  Temperature
0      66.70        41.60         39.9
1       0.42         4.23         28.1
2     335.70       147.70         41.8
3      77.90        37.30         29.8

import seaborn as sns
cm = sns.light_palette("orange", as_cmap=True)
df.style.background_gradient(cmap=cm)

enter image description here

The Styler object applies to the entire DataFrame, so you probably need to apply and present each column.

And the color to describe temperature is usually red, as heat is related to red. There are many variations of red to try out, for example 'darkred', 'tomato', 'indianred', 'firebrick', 'maroon', etc. Refer here for various color options: https://matplotlib.org/stable/gallery/color/named_colors.html

df[['Temperature']].style.background_gradient(cmap=sns.light_palette("red", as_cmap=True))

enter image description here

df[['Hue value']].style.background_gradient(cmap=sns.light_palette("magenta", as_cmap=True))

enter image description here

df[['Green value']].style.background_gradient(cmap=sns.light_palette("lime", as_cmap=True))

enter image description here

blackraven
  • 5,284
  • 7
  • 19
  • 45