MATLAB Answers

John Doe

Legend in biograph plot

Asked by John Doe
on 18 May 2013

I have a biograph object, and I want to "color-code" the edges and vertices.

Is it possible to get legends in the biograph plot, similar to the ones in plot.

My code is:

    Sys = sparse(from_nodes, to_nodes,1,s,s);
    SysTri = tril(Sys + Sys');
    h = view(biograph(SysTri,[],'ShowArrows','off','ShowWeights','off')); 
    %% One of the parts I'm coloring:
    set(h.Nodes(node_list1),'Color',[1 0.4 0.4])
    fowEdges = getedgesbynodeid(h,get(h.Nodes(node_list1),'ID'));
    revEdges = getedgesbynodeid(h,get(h.Nodes(fliplr(node_list1)),'ID'));
    edges = [fowEdges;revEdges];
    set(edges,'LineColor',[1 0 0])

Now, I would like to do something like this:

    legend(h,'Node list 1', 'Node list 2');

Does anyone know if this is possible?

Edit: It doesn't need to be an automatic solution, since I'm not doing this very many times. I know I can manually "Print to figure", and "Insert legends" there, but then every single line gets its own label.

Any help is appreciated. Thanks!


Log in to comment.


No products are associated with this question.

0 Answers

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!