Skip to content

Display Connection Matrix #963

@SoundsSerious

Description

@SoundsSerious

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.
Connectionmap

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy