10

I am plotting subplots of heatmap using seaborn with the following stripped down code. I get "AttributeError: 'numpy.ndarray' object has no attribute 'spines'" if I use nrows=2 and ncols=2, the plot works if either of nrows or ncols=1. How do I fix this?

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
fig, axes  = plt.subplots(nrows=2, ncols=2)
sns.heatmap(Lpnl['19'],ax=axes[0])
plt.show()
3
  • looks like you're potentially using pandas dataframes; have you considered using a seaborn.FacetGrid instead of subplots? Commented Jun 3, 2016 at 2:15
  • @Constantino: Would you be a able to suggest me or point to a link on how to plot multiple heatmaps with FacetGrid? Commented Jun 6, 2016 at 1:14
  • start going through the FacetGrid documentation, it's quite good. Commented Jun 6, 2016 at 14:34

1 Answer 1

21

Your axes variable is a 2x2 numpy array. So when you do axes[0], it is giving you the first row. I assume you want axes[0, 0] or axes.flat[0].

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.