예제 #1
0
def show_ternary(actor: Actor):
    global quantize
    global scale
 
    figure, tax = ternary.figure(scale=scale)
    figure.set_size_inches(6,  6)

    # Set ticks
    tax.ticks(axis='lbr', linewidth=1, multiple=5, offset=0.03)

    # Remove default Matplotlib Axes
    tax.clear_matplotlib_ticks()
    tax.get_axes().axis('off')

    tax.horizontal_line(16)
    tax.left_parallel_line(10, linewidth=2., color='red', linestyle="--")
    tax.right_parallel_line(20, linewidth=3., color='blue')

    #scale = 100
    figure, tax = ternary.figure(scale=scale)
    tax.boundary(linewidth=0.3)
    tax.gridlines(multiple=Settings.get_quantize(), color="gray")

    tax.ax.axis('off')

    size = Settings.get_quantize() / scale * 150    
    
    #simulate stale
    stale = [Element.location for Element in actor.Elements if Element.state == Status.STALE] 
    for p in stale:
        q = [p.coordinates()]
        tax.plot(q, marker='o', color="white", markersize=size*0.8, alpha=0.05, markeredgecolor='gray', markeredgewidth=4.0)
    
    # simulate rejections
    rejected = [Element.location for Element in actor.Elements if Element.state == Status.REJECTED] 
    for p in rejected:
        q = [p.coordinates()]
        tax.plot(q, marker='^', color="white", markersize=size, alpha=0.2 ,markeredgecolor='black', markeredgewidth=1.0  )    
    
    #simulate acceptances
    accepted = [Element.location for Element in actor.Elements if Element.state == Status.ACCEPTED] 
    for p in accepted:
        q = [p.coordinates()]
        tax.plot(q, marker='*', color=p.to_color_string(), markersize=size*1.2, alpha=1.0 )
    
    #highlight new point:
    new = [Element.location for Element in actor.Elements if Element.state == Status.NEW] 
    for p in new:
        q = [p.coordinates()]
        tax.plot(q, marker='o', color=p.to_color_string(), markersize=size+4, alpha=0.9,markeredgecolor='yellow', markeredgewidth=4)
        
    # actor owned Elements:
    owned = [Element.location for Element in actor.Elements if Element.state == Status.OWNED] 
    for p in owned:
        q = [p.coordinates()]
        tax.plot(q, marker='o', color=p.to_color_string(), markersize=size, alpha=1)
    
    # simulate recommendations 
    recommended = [Element.location for Element in actor.Elements if Element.state == Status.RECOMMENDED] 
    for p in recommended:
        q = [p.coordinates()]
        tax.plot(q, marker='*', color="yellow", markersize=size, alpha= 0.8)  
    return figure