1

I have a working sns.heatmap, showing volatility of currency pairs. What I want is to be retain the color from the volatility, but superimpose the numeric spot rate in the relevant cell.

This way each cell displays two values- spot numeric, and volatility color. Is there a way to use sns.heatmap to do this directly, or failing that, grab the graphical info and superimpose the spot data.

halfer
  • 19,824
  • 17
  • 99
  • 186
P Stafford
  • 61
  • 4
  • [This](https://stackoverflow.com/questions/44666679/something-like-plt-matshow-but-with-triangles), [this](https://stackoverflow.com/questions/44291155/plotting-two-distance-matrices-together-on-same-plot) or [this](https://stackoverflow.com/questions/49163305/seaborn-complex-heatmap-drawing-circles-within-tiles-to-denote-complex-annotat) – ImportanceOfBeingErnest Sep 17 '19 at 15:35

2 Answers2

0

never mind, I've found an updated part of seaborn documentation. annot can now be set to an array of values separate from the color map.

P Stafford
  • 61
  • 4
0

Simple example:

import seaborn as sns

data_number = pd.DataFrame(np.random.randint(0, 3, (11,5)), columns=['A', 'B', 'C', 'D', 'E'], index = range(2000, 2011, 1))
data_string = data_number.replace(0,"").replace(1,"Some").replace(2,"Lots")

sns.heatmap(data_number, annot=data_string, 
            xticklabels=data_number.columns,
            yticklabels=data_number.index,
            fmt="s", cmap = sns.cm.rocket_r)

Results in: enter image description here

vladmihaisima
  • 2,119
  • 16
  • 20