Skip to content

Bug for phase tensor ellipse #40

@ralfschaa

Description

@ralfschaa

Hi all,

(very quiet here, is MTPy still developed?)

there seems to be a bug when plotting phase tensor ellipses using the skew angle (beta) with the 'skew_seg' colours.

BUG: negative angles don't get correctly mapped into the assigned color segments

Here is the relevant code in sub get_plot_color in module mtcolors.py:

for bb in range(bounds.shape[0]):                     
    if colorx >= bounds[bb] and colorx < bounds[bb+1]:
        cvar = float(bounds[bb])/bounds.max()         
        return get_color(cvar, cmap)                  

for negative value bounds[bb] is the upper bracket, which however should be the lower bracket.

Proposed solution - use positive values and multiply with the original sign (not thoroughly tested!)

        # Get the sign of the skew angle:                                               
        skew_sign = np.sign(colorx)                                                     
        # New variable to work with                                                     
        abs_color = np.abs(colorx)                                                      
                                                                                        
        # Use original code, start with angles outside given range:                     
        if abs_color > bounds.max():                                                    
            # Restore sign here:                                                        
            cvar = skew_sign*1.0                                                        
            return get_color(cvar, cmap)                                                
                                                                                        
        # Take care of angles in interval:
        for bb in range(bounds.shape[0]):                                               
            if abs_color >= bounds[bb] and abs_color < bounds[bb+1]:                    
                # Restore sign here:                                                    
                cvar = skew_sign*float(bounds[bb])/bounds.max()                         
                return get_color(cvar, cmap)                                            

Cheers
-Ralf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions