Message Boards Message Boards

0
|
4329 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Specific style for a graphic

Posted 10 years ago

I have the following code.

Bk = {{{0, 0}, {62, 61}, 1}, {{0, 0}, {60, 50}, 
    2}, {{0, 50}, {60, 100}, 2}, {{60, 50}, {120, 100}, 2}};

rec = {};
graficar[bk_List] := Module[{placas, lamina, medidas, dibujo,i},
  placas = Max[bk[[;; , 3]]];
  For[i = 1, i <= placas, i++,
   lamina = Most[#] & /@ Cases[bk, {{_, _}, {_, _}, i}];
   dibujo = 
    Graphics[
     Prepend[Apply[Rectangle, lamina, 1], {Red, 
       Rectangle[{0, 0}, {120, 100}]}], 
     PlotLabel -> "Lámina número " <> ToString[i]];
   AppendTo[rec, dibujo]
   ]
  ]
graficar[Bk]

and rec request I get the following graph

i have the graoh.

and I want something like:

goal

Any Help is welcome,thanks in advance.

POSTED BY: Luis Ledesma

With a slight modification it comes out

    In[121]:= Clear[Bk]
    Bk = {{{0, 0}, {62, 61}, 1}, {{0, 0}, {60, 50}, 
        2}, {{0, 50}, {60, 100}, 2}, {{60, 50}, {120, 100}, 2}};

Clear[graficar]
graficar[bk_List] := 
 Module[{placas = Max[bk[[;; , 3]]], lamina, medidas, dibujo, i, rec = {}},
  For[i = 1, i <= placas, i++,
   lamina = Most[#] & /@ Cases[bk, {{_, _}, {_, _}, i}];
   dibujo = Graphics[Prepend[{EdgeForm[{Blue, Thick, Dashed}], Green, Rectangle @@@ lamina}, 
         {Red, Rectangle[{0, 0}, {120, 100}]}], 
         PlotLabel -> "Lámina número " <> ToString[i]
   ];
   AppendTo[rec, dibujo]
  ];
  rec
]

as

rectangles

POSTED BY: Udo Krause
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract