MathGroup Archive 2000

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

Search the Archive

Re: Re: ListPlot with missing values

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22489] Re: [mg22419] Re: ListPlot with missing values
  • From: "Tomas Garza" <tgarza at mail.internet.com.mx>
  • Date: Sat, 4 Mar 2000 02:26:54 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Roy Mendelssohn [rmendels at pfeg.noaa.gov] wrote:


> First, thanks to all who answered.  I clearly didn't explain the problem
> carefully enough.  Assume we are plotting a time series with missing
> data, and only want to conect consecutive points that have data, have
> blanks whenever a time point is missing, and still want points lined up
> correctly in time on the x axis.  If I just delete cases, then the
> endpoints of any missing segment will be connected, rather than being
> blank.
>
> In the example
>
> alist = {{1, 1}, {2, 3}, {3,5},{4,}, {5, 6}, {6,8},{7,}, {8,10},{9, 12}}
>
> I want a line joing the first three points, then a blank, then a line
> connecting the next two points, then a blank etc.
>
> The reason I mentioned the number of datapoints is because one solution
> is to draw a graph for each uninterrupted segment of the time series,
> and then overlay them.  This seems inelegant,because several hundred
> separate graphs might have to be drawn.
>
> If anyone else has other suggestions I would welcome them.

If you take alist exactly as you have it in your message, then

In[1]:=
alist = {{1, 1}, {2, 3}, {3, 5}, {4,}, {5, 6}, {6, 8}, {7,}, {8, 10}, {9,
      12}}

Out[1]=
{{1, 1}, {2, 3}, {3, 5}, {4, Null}, {5, 6}, {6, 8}, {7, Null}, {8, 10}, {9,
    12}}

Then you plot it:

In[2]:=
ListPlot[alist, PlotJoined -> True]

You get two error messages:

Graphics::"gptn": "Coordinate Null in {4, Null}
floating-point number."

Graphics::"gptn": "Coordinate Null in {7, Null}is not a
floating-point number."

Never mind, you'll get your plot as desired (try it). But, if you wish, you
could write something more elaborate in order not to get error messages
(which is not elegant, even if you get your plot). Try, for example,

In[1]:=
pts = Transpose[{Drop[alist, -1], Rest[alist]}];
In[2]:=
lines = Line /@ Select[pts, NumericQ[#[[1, 2]]] && NumericQ[#[[2, 2]]] &];
In[3]:=
Show[Graphics[lines], Axes -> True, AxesOrigin -> {0, 0},
  PlotRange -> {{0, 10}, {0, 12}}]

Tomas Garza
Mexico City




  • Prev by Date: Re: Digitizing points in a graphic (amendment)
  • Next by Date: Re: J/Link preview release
  • Previous by thread: Re: Re: ListPlot with missing values
  • Next by thread: Re: ListPlot with missing values