Skip to main content
Tweeted twitter.com/StackMma/status/1340446942871113730
edited tags
Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
edited tags
Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
added 290 characters in body
Source Link
MathX
  • 1.7k
  • 12
  • 19

I have made an animated graph that shows the changes of certain functions in time with different vertex sizes and colors:

gr = TreeGraph[RandomInteger[#] <-> # + 1 & /@ Range[0, 30], 
   VertexSize -> 0];

Manipulate[
 Show[{SetProperty[
    gr, {VertexSize -> 
      Table[ii -> 0.4 Sin[ii tstep]^2, {ii, VertexList[gr]}], 
     VertexStyle -> 
      Table[ii -> ColorData["Rainbow"][Cos[ii tstep]^2], {ii, 
        VertexList[gr]}]}], 
   Graphics[
    Text[Style[StringJoin["T=" , ToString[tstep]], Bold, 20], 
     Scaled[{0, 1}]], ImageSize -> {250, 100}]}], {tstep, 0, 5, 0.1}]

A sample result looks like this:

enter image description here

How can I add a legend to show the scale of vertex sizes and colors? The closest solution I found was this one but I don't know how to implement the scaling part for what's shown in the legend to follow the style of the graph nodes.

I have made an animated graph that shows the changes of certain functions in time with different vertex sizes and colors:

gr = TreeGraph[RandomInteger[#] <-> # + 1 & /@ Range[0, 30], 
   VertexSize -> 0];

Manipulate[
 Show[{SetProperty[
    gr, {VertexSize -> 
      Table[ii -> 0.4 Sin[ii tstep]^2, {ii, VertexList[gr]}], 
     VertexStyle -> 
      Table[ii -> ColorData["Rainbow"][Cos[ii tstep]^2], {ii, 
        VertexList[gr]}]}], 
   Graphics[
    Text[Style[StringJoin["T=" , ToString[tstep]], Bold, 20], 
     Scaled[{0, 1}]], ImageSize -> {250, 100}]}], {tstep, 0, 5, 0.1}]

A sample result looks like this:

enter image description here

How can I add a legend to show the scale of vertex sizes and colors?

I have made an animated graph that shows the changes of certain functions in time with different vertex sizes and colors:

gr = TreeGraph[RandomInteger[#] <-> # + 1 & /@ Range[0, 30], 
   VertexSize -> 0];

Manipulate[
 Show[{SetProperty[
    gr, {VertexSize -> 
      Table[ii -> 0.4 Sin[ii tstep]^2, {ii, VertexList[gr]}], 
     VertexStyle -> 
      Table[ii -> ColorData["Rainbow"][Cos[ii tstep]^2], {ii, 
        VertexList[gr]}]}], 
   Graphics[
    Text[Style[StringJoin["T=" , ToString[tstep]], Bold, 20], 
     Scaled[{0, 1}]], ImageSize -> {250, 100}]}], {tstep, 0, 5, 0.1}]

A sample result looks like this:

enter image description here

How can I add a legend to show the scale of vertex sizes and colors? The closest solution I found was this one but I don't know how to implement the scaling part for what's shown in the legend to follow the style of the graph nodes.

Source Link
MathX
  • 1.7k
  • 12
  • 19
Loading