I wish to show 20 circles in a vertical rectangular whose m
circles are filled. n
circles for example colored by green
and m-n
colored by red
. The radius of circles are the same and can be r
. The circles are not filled are empty. How do I reach this aim?
I wish to specify the position of green circles and red circles manually. For example: the first be green, the second be red, the third be green and the fourth, the remainder be empty. AND NOT Random.
$\begingroup$
$\endgroup$
1
2 Answers
$\begingroup$
$\endgroup$
3
Here's another way:
colors = {Green, Red, Green, Sequence @@ ConstantArray[White, 17]};
r =
Table[Rectangle[{m, n}, RoundingRadius -> .5], {m, 1}, {n, 20}];
Graphics[{EdgeForm[Blue], Riffle[Reverse@colors, Flatten@r]},
Frame -> True, FrameStyle -> Directive[Blue, Bold],
FrameTicks -> None]
-
$\begingroup$ You just need to specify your desired order in
colors
. I was doing something similar withRectangles
, so that's why I use them here instead of explicit circles (RoundingRadius->0.5
of aRectangle[]
equals a circle). $\endgroup$ Commented Feb 19, 2018 at 23:21 -
$\begingroup$ Thank you so much, your approach is very near to what I was searching, $\endgroup$ Commented Feb 20, 2018 at 5:45
-
$\begingroup$ @Irreversible, glad I could help! $\endgroup$ Commented Feb 20, 2018 at 7:29
$\begingroup$
$\endgroup$
3
Here's one way:
GraphicsColumn[Table[Graphics[{RandomChoice[{Green, Red, White}],
Disk[{i, 0}, 0.4], Black, Circle[{i, 0}, 0.4]}], {i, 20}]]
-
$\begingroup$ Thank you so much. But I wish to specify the position of green circles and red circles manually. For example: the first be green, the second be red, the third be green and the fourth, the remainder be empty. AND NOT Random. $\endgroup$ Commented Feb 19, 2018 at 19:37
-
$\begingroup$ @Irreversible What have you tried and where did you get stuck? This answer shows the basics. You can just as easily pull the colour from another list indexed by
i
. $\endgroup$– SzabolcsCommented Feb 19, 2018 at 20:34 -
$\begingroup$ @Szabolcs, I have exploited
GraphicsColumn[{Graphics[Disk[]], Graphics[Disk[]], Graphics[Disk[]]}, (which is in the help Mathematica) Frame -> All]
, But unfortunately I had to create twenty copies of the line for specifying the position of colored circles. $\endgroup$ Commented Feb 20, 2018 at 5:44
Disk
andGraphics
. $\endgroup$