0

plotDF is as follows:

enter image description here

plots['SPX'] is as follows: enter image description here

i have managed to produce my intended seaborn heatmap plot using:

fig, ax = plt.subplots(figsize=(20,10))  
ax=sns.heatmap(plotDF,vmin=-0.15, vmax=1,cmap='YlGnBu')

enter image description here

i am now trying to add a line plot on a second y axis but when doing so it is not overlaying the x-axis correctly. I am using the following code and getting the outcome below:

fig, ax = plt.subplots(figsize=(20,10))  
ax=sns.heatmap(plotDF,vmin=-0.15, vmax=1,cmap='YlGnBu')
ax2=plt.twinx()
sns.lineplot(data=plots['SPX'],ax=ax2,linewidth=1)
ax.axis('tight')

enter image description here

appreciate any help available. I have been trying various similar solutions for the last few hours. Thanks in advance.

Steve
  • 13
  • 3
  • This question was closed as a duplicate to a bunch of questions about bar plots because the tick locations of a heatmap work the same way as a bar plot (they are 0 indexed). A line plot with a timeseries x, is not 0 indexed. Specifically see the explanation in this [answer](https://stackoverflow.com/a/60958889/7758804) – Trenton McKinney Nov 27 '21 at 16:54

0 Answers0