0

I'd like to see all my subplots (the data is correct) and have them flush with no axes. As in, one grid with no spaces from start to finish of nothing but heatmaps.

I've read plt.tight_layout can fix missing subplots but that did not pan out for me. Nor did plt.axis('off'). There may be a way to dynamically use ax to turn off the axes, but hasn't worked so far. I've also tried the gridspec to close the spaces but that isn't working for me.

from keras import backend as K
import matplotlib.gridspec as gridspec
lay_len = len(model_m.layers)

activities = list(mapping.keys())
act_len = len(activities)
plt.figure(figsize = (act_len,lay_len))
gs1 = gridspec.GridSpec(act_len,lay_len)
gs1.update(wspace=0, hspace=0) # set the spacing between axes.

j=1
outputs = []
for layer in range(1,lay_len):
        for i in range(0,len(activities)):
            seg_x = create_segments_and_labels(df[df['ActivityEncoded']==i],TIME_PERIODS,STEP_DISTANCE,LABEL)[0]
            get_layer_output = K.function([model_m.layers[0].input],[model_m.layers[layer].output])
            layer_output = get_layer_output([seg_x])[0]
            plt.subplot(lay_len,len(activities),j)
            try: 
            #    outputs.insert(j,layer_output[0])
                sns.heatmap(layer_output[0],cbar=False)
            except:
            #    outputs.insert(j,layer_output)
                sns.heatmap(layer_output,cbar=False)
            j = j+1
plt.tight_layout
plt.axis('off')

https://i.stack.imgur.com/KAW9c.jpg

No errors.

Mark McGown
  • 975
  • 1
  • 10
  • 26
  • [This](https://stackoverflow.com/questions/42475508/how-to-combine-gridspec-with-plt-subplots-to-eliminate-space-between-rows-of-s/42481878#42481878), [this](https://stackoverflow.com/questions/41071947/how-to-remove-the-space-between-subplots-in-matplotlib-pyplot?rq=1) – ImportanceOfBeingErnest Oct 14 '19 at 01:58
  • The sns.heatmap seems to be overwriting all rows prior to the last row. How can I apply the links to ax to sns.heatmap rather than 'im'? – Mark McGown Oct 14 '19 at 03:45

0 Answers0