- Notifications
You must be signed in to change notification settings - Fork441
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.
defmake_connection_plot(self):iinx= {}oinx= {}sinx= {}# Go through the system list and keep track of counts, offsetsforsysidx,sysinenumerate(self.syslist):forstinrange(sys.nstates):iinx[max(iinx.keys())+1ifiinxelse0+st]=f'{sys.name}.{sys.state_labels[st]}'forstinrange(sys.noutputs):oinx[max(oinx.keys())+1ifoinxelse0+st]=f'{sys.name}.{sys.output_labels[st]}'forstinrange(sys.ninputs):sinx[max(sinx.keys())+1ifsinxelse0+st]=f'{sys.name}.{sys.input_labels[st]}'cmm=self.connect_map.copy()cmm[cmm==0]=np.nanimshow(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