-
Notifications
You must be signed in to change notification settings - Fork 442
Open
Description
Hi,
I wanted to expand on #925 and display a sparse graph of all the system connections, some of which had the same signal name, which is a case I found the new connection table feature a bit confusing for so I wrote this short function to display the connection matrix directly using matplotlib imshow.
def make_connection_plot(self):
iinx = {}
oinx = {}
sinx = {}
# Go through the system list and keep track of counts, offsets
for sysidx, sys in enumerate(self.syslist):
for st in range(sys.nstates):
iinx[ max(iinx.keys())+1 if iinx else 0 + st] = f'{sys.name}.{sys.state_labels[st]}'
for st in range(sys.noutputs):
oinx[ max(oinx.keys())+1 if oinx else 0 +st] = f'{sys.name}.{sys.output_labels[st]}'
for st in range(sys.ninputs):
sinx[max(sinx.keys())+1 if sinx else 0 +st] = f'{sys.name}.{sys.input_labels[st]}'
cmm = self.connect_map.copy()
cmm[cmm==0] = np.nan
imshow(cmm)
grid()
title(f'Connection Map: {self.name}')
xticks(ticks=list(oinx.keys()),labels=list(oinx.values()),rotation=90)
yticks(ticks=list(sinx.keys()),labels=list(sinx.values()))
xlabel('Outputs')
ylabel('Inputs')
tight_layout()
This code results in this plot, displaying the gain via color as well as the scoped input and output names.
Metadata
Metadata
Assignees
Labels
No labels