From: sandric ionut <sandricionut@ya...>  20080628 14:16:24

Thank you Darren: The second example is what I need. I have made some test and it looks OK I have my data in excel. How can I read from excel files? Is it a special tool? Thank you again, Ionut  Original Message  From: Darren Dale <dsdale24@...> To: matplotlibusers@... Cc: sandric ionut <sandricionut@...> Sent: Saturday, June 28, 2008 3:12:48 PM Subject: Re: [Matplotlibusers] plot xy data with missing values Hi Sandric, On Saturday 28 June 2008 04:31:19 sandric ionut wrote: > Hello: > I want to draw a multiple line plot using the data from the bottom of the > email, but I get a error message: <type 'exceptions.AssertionError'>: > Dimensions of x and y are incompatible, which is normal, because the number > of values on x are not equal with the number of values on y. The empty > spaces from the table are missing values (which were not measured for a > certain moment in time) and I can't replace them with any other values It is more robust to use a NaN to represent a missed data point. Then when you load your data, your arrays will be the same length. There is already some support for plotting data with NaNs in it, but the preferred solution is to take a further step and use a masked array to mask your missing values. For example, at the ipython pylab prompt: time=array([1,2,3,4,5]) f1=array([1,2,NaN,4,5]) f1_m=ma.masked_where(isnan(f1),f1) plot(f1_m) That will give you a line with a break in it at the missed observation. > Is it possible to interpolate the missing values or to the draw the plot as: > on x the time values and on y the f1,f2,f3, represented as a continuous > line If you do not want breaks in your line due to the missed observation, you could interpolate the missing values yourself, but if you just want a continuous line through whatever data you have, you could use numpy's flexible indexing and do: plot(time[isfinite(f1)], f1[isfinite(f1)]) > The plot should look like the image attached, but with a line crossing > all the points for f1, f2, f3 > > time f1 f2 f3 > 30 3.39 13.55 > 33 16.94 > 35 6.78 > 36 10.16 > 37 10.16 13.55 > 38 13.55 > 39 16.94 16.94 > 40 20.33 > 41 20.33 20.33 > 42 23.71 > 44 23.71 All of my suggestions are based on the assumption that you have recorded missing values as NaNs. If you can't reformat your data, or insert NaN's for missing values when you load it, I'm not sure how to help. Darren 