I like to practice writing the code from the Dataquest lessons in my own Jupyter Notebook, but in this case, I’m getting the opposite colors from the lesson on the Dataquest platform, and I’m wondering what’s wrong. Is it a setting in Jupyter notebook?
def plot_null_matrix(df, figsize=(18,15)):
# initiate the figure
plt.figure(figsize=figsize)
# create a boolean dataframe based on whether values are null
df_null = df.isnull()
# create a heatmap of the boolean dataframe
sns.heatmap(~df_null, cbar=False, yticklabels=False)
plt.xticks(rotation=90, size='x-large')
plt.show()
plot_null_matrix(mvc.head(1), figsize=(18,1))
What I expected to happen:
What actually happened:
If I ran the same code as Dataquest, why are the light and dark colors reversed. Is there a Jupyter Notebook setting that I need to set?
The function may be the same, but results differ if the code/data calling the function is different.
If i remember right, yellow is True, black is False. The data may have inverted boolean values.
I think it might be a setting somewhere, but I don’t know what it is. If I run the code in the DQ interface, I get the matching heatmap you see on the screen. If I use it locally with Jupyter, the colors are inverted. When I changed cbar = True, it displayed the color gradient being used, and you can see the colors inverted.
I know the DQ interface uses Matplotlib 1.5.1, and I have Matplotlib 3.1.3 on my machine. I don’t know if that makes the difference in the direction of the gradient. Maybe there’s a setting somewhere that flips it around. No clue!
Just wanted to let you know it’s not just you. If you ever get it figured out, let me know!