Home > Enterprise >  How to plot a (22, 3, 2) matrix list of lists as a scatter plot?
How to plot a (22, 3, 2) matrix list of lists as a scatter plot?

Time:08-11

I am trying to plot the below sensitivity matrix into a plot that consists of each list as sub-plot in it. Preferably as a function and look like enter image description here

CodePudding user response:

The first point is to transform the data, so I am transforming it by changing the dimensions. The graph is drawn in a loop procedure with that transformed array. Empty graphs are manually deleted, so please adjust them. The number of data presented does not match the number of graphs, but please adjust the number of graphs to match my code to your data.

fig, axs = plt.subplots(5, 4, figsize=(9,9))
fig.subplots_adjust(wspace=0.5,hspace=0.5)

def scatter_plot(data):
    for d,ax in zip(data, axs.flatten()):
        xy = d.flatten().reshape(2,3, order='F')
        ax.scatter(xy[0], xy[1])
    fig.delaxes(axs[4,1])
    fig.delaxes(axs[4,2])
    fig.delaxes(axs[4,3])
    plt.show()

scatter_plot(data)

enter image description here

  • Related