Automatically adjust HTML table text color when using `style.background_gradient()` #21258
import pandas as pd import numpy as np np.random.seed(24) df = pd.DataFrame(np.random.randn(8, 4), columns=list('ABCD')) df.style.background_gradient()
Since all text in the displayed HTML table is black, it is difficult to see values when the background is dark. This is currently possible to adjust manually with the
A possible improvement would be to color text white automatically if the background color is too dark (low luminance). This approach is currently implemented for annotated heatmaps in the visualization library
Automatic text coloring could be exposed through a
If you think adding this functionality would be useful, I am happy to attempt a PR.