Graphical presentation of lists

Say I have three lists: a={1,5,10,15} b={2,4,6,8} and c={1,1,0,1,0} . I need a graph that has a as the x axis, b as the y axis, and the red / black dot is 1/0. For. for example, Coordinate (5,4) will have a red dot.
In other words, the coordinate (a[i],b[i]) will have a red / black dot depending on whether c[i] 1 or 0.
I tried my hand with ListPlot , but cannot determine the options.

+6
wolfram-mathematica
source share
5 answers

I suggest this.

 a = {1, 5, 10, 15}; b = {2, 4, 6, 8}; c = {1, 1, 0, 1}; Graphics[ {#, Point@ {##2}} & @@@ Thread@ {c /. {1 -> Red, 0 -> Black}, a, b}, Axes -> True, AxesOrigin -> 0 ] 

Mathematica graphics

Or shorter but more confusing

 Graphics[ {Hue[1, 1, #], Point@ {##2}} & @@@ Thread@ {c, a, b}, Axes -> True, AxesOrigin -> 0 ] 
+8
source share

Leonidโ€™s idea is perhaps more naive.

 f[a_, b_, c_] := ListPlot[Pick[Transpose[{a, b}], c, #] & /@ {0, 1}, PlotStyle -> {PointSize[Large], {Blue, Red}}] f[a, b, c] 

enter image description here

Edit: just for fun

 f[h_, a_, b_, c_, opt___] := h[Pick[Transpose[{a, b}], c, #] & /@ {0, 1}, PlotStyle -> {PointSize[Large], {Blue, Red}}, opt] f[ ListPlot, Sort@RandomReal [1, 100], Sin[(2 \[Pi] #)/100] + RandomReal[#/100] & /@ Range[100], RandomInteger[1, 100], Joined -> True, InterpolationOrder -> 2, Filling -> Axis] 

enter image description here

+7
source share

Here are your questions:

 a = {1, 5, 10, 15}; b = {2, 4, 6, 8}; c = {1, 1, 0, 1}; 

(I removed the last element from c to make it the same length as a and b ). I suggest separately making images for points with zeros and ones, and then combining them - this seems to be the easiest in this situation:

 showPoints[a_, b_, c_] := With[{coords = Transpose[{a, b}]}, With[{plotF = ListPlot[Pick[coords, c, #], PlotMarkers -> Automatic, PlotStyle -> #2] &}, Show[MapThread[plotF, {{0, 1}, {Black, Red}}]]]] 

Here is the usage:

 showPoints[a, b, c] 

enter image description here

+6
source share

One possibility:

 ListPlot[List /@ Transpose[{a, b}], PlotMarkers -> {1, 1, 0, 1} /. {1 -> { Style[\[FilledCircle], Red], 10}, 0 -> { { Style[\[FilledCircle], Black], 10}}}, AxesOrigin -> {0, 0}] 

As a conclusion:

enter image description here

+5
source share

You can get similar results (e.g. with Leonid) using Graphics:

  Graphics[{PointSize[.02], Transpose[{(c/. {1 -> Red, 0 -> Black}), Point /@ Transpose[{a, b}]}]}, Axes -> True, AxesOrigin -> {0, 0}] 

Using Graphics instead of ListPlot

+4
source share

All Articles