1
$\begingroup$

I'd like to use ComplexListPlot to show a point and its image under a complex function, with the point and image having different styles, say different colors.

Use, for example:

z1 = 3 + 4 I;
f[z_] := Sin[20/z]

The following will do what I want:

pt = ComplexListPlot[{z1}, PlotRange -> {-1 - 2 I, 10 + 10 I}, 
   PlotStyle -> {PointSize[Large], Red}];
val = ComplexListPlot[{f[z1]}, PlotRange -> {-1 - 2 I, 10 + 10 I}, 
   PlotStyle -> {PointSize[Large], Green}];
Show[{pt, val}, ImageSize -> Small]

A complex point and its image under a complex function.

But is there a simpler way, using a single ComplexListPlot expression?

I tried the following, but it just applies the first entry (with Red) to both points:

ComplexListPlot[{z1, f[z1]}, PlotRange -> {-1 - 2 I, 10 + 10 I}, 
 PlotStyle -> {{PointSize[Large], Red}, {PointSize[Large], Green}}, 
 ImageSize -> Small]

I may be "pushing" ComplexListPlot to do something for which it was not really intended, but as things stand I see no other way to plot points in the complex plane in different styles while still using complex numbers and not (real,imag) pairs of reals.

Before version 12's ComplexListPlot, I would create the image with David Park's Presentations add-on application as follows:

Draw2D[{PointSize[Large], Red, ComplexPoint[z1], Green, 
  ComplexPoint[f[z1]]}]
$\endgroup$
1
$\begingroup$

Use an additional set of list braces to separate datasets, and while not needed, you can use Directive to collect directives:

ComplexListPlot[
    {{z1},{f[z1]}},
    PlotRange->{-1-2 I,10+10 I},
    PlotStyle->{
        Directive[PointSize[Large],Red], (* style for first dataset *)
        Directive[PointSize[Large],Green] (* style for second dataset *)
    },
    ImageSize->Small
]

enter image description here

$\endgroup$
  • $\begingroup$ Yes, I'm aware of how to use Directive to produce a more verbose, but possibly more readable, treatment. However, having to create a list of two lists of complex numbers seems an "excessive" way to be forced to vary the styling. $\endgroup$ – murray Jun 12 at 19:23
  • $\begingroup$ @murray If you have a single list of complex numbers, how does Mathematica know whether each number should have the same color, or each should have different colors? $\endgroup$ – Carl Woll Jun 12 at 20:07
  • $\begingroup$ With a PlotStyle target of form {*specs1*,*specs2*} where specs1 and specs2 are lists of styles,it would not seem unreasonable that the 1st point is treated by specs1 and the 2nd point is treatec by specs2 (and if there's only a single, unnested list as target of PlotStyle, then the targe is applied to both points). Am I missing seeing some conflict? $\endgroup$ – murray Jun 12 at 20:15
1
$\begingroup$

You can also wrap each point with Style:

ComplexListPlot[MapThread[Style, {{z1, f@z1}, {Red, Green}}],
  PlotRange -> {-1-2 I, 10+10 I}, BaseStyle -> PointSize[Large], ImageSize -> Small]

or

ComplexListPlot[MapThread[Style[##, PointSize[Large]] &, {{z1, f@z1}, {Red, Green}}],
  PlotRange -> {-1 - 2 I, 10 + 10 I}, ImageSize -> Small]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Ahh..., I forgot about Style. More directly: ComplexListPlot[{Style[z1, Red], Style[f[z1], Green]}, PlotStyle -> PointSize[Large], PlotRange -> {-1 - 2 I, 10 + 10 I}, ImageSize -> Small]. $\endgroup$ – murray Jun 12 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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