MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Plotting just specific points


On 2/9/05 at 9:27 AM, chocolatez at gmail.com (zak) wrote:

>if i have the list: a={5,1,2,2,6,7,2,2,8,2} and in the ListPlot[a] 
>i want to show only the points wich represent only the "2" while
>preserving the positions of the "2" in the list, so i could focus
>my attention to a specific wanted values, how could i do that

a = {5, 1, 2, 2, 6, 7, 2, 2, 8, 2}; 
ListPlot[Select[Transpose@{Range@Length@a, a}, Last@# == 2&]]; 

>or even better if it is possible to plot the whole values of
>ListPlot[a] while making the points "2" in red color as an example.

b = Transpose@{Range@Length@a, a}; 
Show[
  Block[{$DisplayFunction = Identity}, 
    {ListPlot[Select[b, Last@# != 2&]], 
     ListPlot[Select[b, Last@#1 == 2&], 
      PlotStyle -> {PointSize[0.015], Hue[0]}]}]];

And there are many other variations on these. For example, I could have constructed b in the code above as:

b = MapIndexed[Flatten@{#2,#1}&,a]

or

b = MapThread[List, {Range@Length@a, a}]

or I could use LabeledListPlot or MultipleListPlot in the Graphics add ons. For example,

<< "Graphics`"; 
LabeledListPlot[
  MapThread[
    {#1, #2, If[#2 == 2, "2", ""]} & , 
    {Range[Length[a]], a}], 
   AxesOrigin -> {0, 0}, 
   PlotRange -> {{0, 11},{0, 8.2}}]; 
--
To reply via email subtract one hundred and four


  • Prev by Date: Problems with easy simplifications
  • Next by Date: Re: Simplify problems for checking easy equalities...
  • Previous by thread: Re: Plotting just specific points
  • Next by thread: Domain and range