Home > Software design >  Unwanted spaces in heat map
Unwanted spaces in heat map

Time:05-31

Hi I would like to use a heat map to show the variations of deuterium in precipitation over a period of time. For this I have used the following code: (source: enter image description here

How can I delete them?

CodePudding user response:

If you used the example in the link (source: link ) you can commented those line:

# ax.spines[:].set_visible(False)

# ax.set_xticks(np.arange(data.shape[1] 1)-.5, minor=True)
# ax.set_yticks(np.arange(data.shape[0] 1)-.5, minor=True)
# ax.grid(which="minor", color="w", linestyle='-', linewidth=3)
# ax.tick_params(which="minor", bottom=False, left=False)

The white grid is display through those line

You can add a parameter to show it or not

def heatmap(data, row_labels, col_labels, ax=None,
        cbar_kw={}, cbarlabel="", grid = False, **kwargs):

    ...
    if grid:
        ax.spines[:].set_visible(False)
    
        ax.set_xticks(np.arange(data.shape[1] 1)-.5, minor=True)
        ax.set_yticks(np.arange(data.shape[0] 1)-.5, minor=True)
        ax.grid(which="minor", color="w", linestyle='-', linewidth=3)
        ax.tick_params(which="minor", bottom=False, left=False)

CodePudding user response:

Try using

plt.rcParams["axes.grid"] = False
  • Related