5
$\begingroup$

I want to draw this elementary graph, shown below.

Sample Diagram

The exact path of the blue line is not important. I want to keep the blue dots to the left of the line and keep the red dots to the right of it.

I have tried the following code, but it failes to properly curve the straight line to keep all the blue dots to the left.

k = 3;
poles1 = Table[{i, 0}, {i, 0, k}];
poles2 = Table[{1/2 - n, 0}, {n, 0, k}]; 
Show[
  Plot[100 Sign[x + 1/4], {x, -k, k}, 
    ExclusionsStyle -> Blue, 
    PlotRange -> {-3, 3}, 
    AxesStyle -> Directive[Blue, 13]], 
  Graphics[{PointSize[0.02], Red, Point[poles1]}], 
  Graphics[{PointSize[0.02], Blue, Point[poles2]}]]

Any help will be highly appreciated.

$\endgroup$
3
  • 2
    $\begingroup$ Is this a one-off? Then do it by hand in a graphics program. You’ll be done in no time. If you want to be able to do it programmatically for variable input, then you need to tell us more about the form of the input and the line. $\endgroup$
    – MarcoB
    Jan 29, 2021 at 13:34
  • 3
    $\begingroup$ "The exact path of the blue line is not important" - Would With[{k = 3}, poles1 = Table[{i, 0}, {i, 0, k}]; poles2 = Table[{1/2 - n, 0}, {n, 0, k}]; Graphics[{{PointSize[0.02], Red, Point[poles1]}, {PointSize[0.02], Blue, Point[poles2]}, {Blue, HalfLine[{-1/4, 0}, {0, -1}], Circle[{0, 0}, 1/4, {0, π}], Circle[{1/2, 0}, 1/4, {π, 2 π}], Circle[{0, 0}, 3/4, {0, π/2}], Circle[{0, 1}, 1/4, {-π/2, -π}], HalfLine[{-1/4, 1}, {0, 1}]}}, Axes -> True, PlotRange -> 3]] suit your needs? $\endgroup$ Jan 29, 2021 at 13:40
  • $\begingroup$ @J.M. This is also perfect. Thanks a lot for giving your time. $\endgroup$
    – Epsilon
    Jan 29, 2021 at 14:08

2 Answers 2

8
$\begingroup$

Why not the new-in-12.2 Canvas?:

k = 3;
poles1 = Table[{i, 0}, {i, 0, k}];
poles2 = Table[{1/2 - n, 0}, {n, 0, k}]; 
Show[Graphics[{PointSize[0.02], Red, Point[poles1]}], 
  Graphics[{PointSize[0.02], Blue, Point[poles2]}], Axes -> True, PlotRange -> 3, 
  AxesStyle -> Directive[Blue, 13]] // Canvas

enter image description here

$\endgroup$
1
  • $\begingroup$ You deserve a huge thanks! $\endgroup$
    – Epsilon
    Jan 29, 2021 at 14:04
7
$\begingroup$

This is the answer given by J.M.in a comment to the question. It deserves to be recorded as a proper answer, so I'm posting it as a community wiki.

With[{k = 3},
  poles1 = Table[{i, 0}, {i, 0, k}]; 
  poles2 = Table[{1/2 - n, 0}, {n, 0, k}]];

Graphics[
  {{PointSize[0.02],
     {Red, Point[poles1]}, {Blue, Point[poles2]}},
   {Blue,
     HalfLine[{-1/4, 0}, {0, -1}],
     Circle[{0, 0}, 1/4, {0, π}], Circle[{1/2, 0}, 1/4, {π, 2 π}], 
     Circle[{0, 0}, 3/4, {0, π/2}], Circle[{0, 1}, 1/4, {-π/2, -π}], 
     HalfLine[{-1/4, 1}, {0, 1}]}},
  Axes -> True,
  PlotRange -> 3]

plot

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.