python – How can I force seaborn or matplotlib to always render isolated values in heatmaps?

I am analyzing long series of events using heatmaps. Values of the column are most of the time 0 but occasionally are 1 unfortunately the rendering behaviour often hide the 1 occurrences because of the 0 surrounding them. I have tried to use antialiased=False but it did not solve the problem:

This code reproduce the issue:

import numpy as np
import pandas as pd
import seaborn as sns
d = pd.DataFrame(np.zeros((2000, 4)))
for i in range(4):
    for j in [34,223,56,666]:
        d[i][j] = 1
axS = sns.heatmap(d,antialiased=False)

enter image description here

There should be 4 lines instead only one is visible. Of course, if I stretch the plot I have better results but still some values are hidden.

import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (10,30)
axB = sns.heatmap(d,antialiased=False)

I would like to force the rendering of isolated values. Is there any way to get this behaviour?

P.S. I need heatmaps because I compare multiple variables with float values, so spy for instance is not a good option for me.

Read more here: Source link