I'm trying to generate a set of cylinders/tubes with different radii and colours.
In particular, I have this graph: {1 -> 2, 2 -> 3, 3 -> 4, 4 -> 5, 5 -> 1}
with the following vertexes {0, 0, 0}, {0, 0, 10}, {10, 0, 10}, {10, 10,
0}, {5, 15, 10}
.
Furthermore, I have a list of values b = {1, 3, 0.5, -1, -2}
and I want to plot 5 tubes (one for each value) with a specified radius r1
if the related element of b
is greater than zero, and r2
if it is <0. How can I do this? Also, I want to plot these tubes with a range of colours consistent with the vector b
and a
framed bar legend. Thanks.
q = {1, 3, 0.5, -1, -2};
Grafo = Graph[{1 <-> 2, 2 <-> 3, 3 <-> 4, 4 <-> 5, 5 <-> 1},
EdgeWeight -> q];
el = EdgeList[Grafo];
edgestylea =
Thread[el -> (Directive[
ColorData[{"TemperatureMap", {Min[q], Max[q]}}][#]] & /@ q)];
Legended[Graph3D[Grafo, EdgeStyle -> edgestylea,
EdgeShapeFunction -> ({ColorFunction -> (ColorData[
"TemperatureMap", #] & /@ q),
Cylinder[#, If[# < 0, 0.1, 0.5] & /@ q]} &),
VertexLabels -> "Name",
VertexShapeFunction -> ({Yellow, Sphere[#, 1]} &),
VertexCoordinates -> {{0, 0, 0}, {0, 0, 10}, {10, 0, 10}, {10, 10,
0}, {5, 15, 10}}, AxesOrigin -> {0, 0, 0}, Axes -> True,
Ticks -> Automatic,
PlotLabel ->
Style[Framed["Tensegrity", RoundingRadius -> 10], 14, Black,
FontFamily -> "Times New Roman"], AxesLabel -> {x, y, z},
LabelStyle -> {FontFamily -> "Times New Roman"}],
Framed[BarLegend[{"TemperatureMap", {Min[q], Max[q]}},
LegendLabel -> "Internal force" ,
LabelStyle -> {FontFamily -> "Times New Roman"}],
RoundingRadius -> 10, FrameStyle -> GrayLevel[.5]]]
In my code, tubes with different radii consistent with b don't work! Someone can help me?