Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## Re: [Matplotlib-users] iregular data set

 Re: [Matplotlib-users] iregular data set From: John Hunter - 2006-07-21 19:06:51 ```>>>>> "Rodrigues," == Rodrigues, Joseph writes: Rodrigues> Yes, I am plotting two lines and am using two plots, Rodrigues> the two lines plots just fine in different colors, Rodrigues> however, one line is continuous from 1983 - 1995 and Rodrigues> the other dataset has irregular data points along the Rodrigues> same period of time. So I should see a continuous Rodrigues> line for the first data set and I should see a broken Rodrigues> line only where there is data for the second. Rodrigues> Matplotlib is joining the broken points and forces Rodrigues> both datasets to appear as continuous. matplotlib doesn't make any assumptions about whether data is continuous or not. It only knows about points and line styles. If you want a set of points to be connected, use a linestyle like '-' (solid line) or '--' (dashed line) plot(x, y, '-') if you don't want the points to be connected, use a marker like 'o' for circles and 's' for squares plot(x, y, 's') You will need to extract the subsets of the data that you want connected yourself. JDH ```

 Re: [Matplotlib-users] iregular data set From: Rodrigues, Joseph - 2006-07-21 19:03:10 Attachments: Message as HTML ```Yes, I am plotting two lines and am using two plots, the two lines plots just fine in different colors, however, one line is continuous from 1983 - 1995 and the other dataset has irregular data points along the same period of time. So I should see a continuous line for the first data set and I should see a broken line only where there is data for the second. Matplotlib is joining the broken points and forces both datasets to appear as continuous. =20 What do you think is the solution? Thanks Joseph =20 _____ =20 From: Michael Schwager [mailto:hws@...]=20 Sent: Friday, July 21, 2006 2:33 PM To: Rodrigues, Joseph; matplotlib-users@... Subject: RE: [Matplotlib-users] iregular data set =20 Hi, I'm also new to matplotlib, but this sounds like a general type of problem you might in find in matlab too. I think you are trying to plot two separate lines, one for the first set of time and one for the second set of time. If you don't want them connected then you must issue two plot() commands, which means you have to split the data into the sections that you want connected. =20 Michael =20 _____ =20 From: matplotlib-users-bounces@... [mailto:matplotlib-users-bounces@...] On Behalf Of Rodrigues, Joseph Sent: Friday, July 21, 2006 11:25 AM To: matplotlib-users@... Subject: [Matplotlib-users] iregular data set =20 I have a question (new user here): I have datasets of irregular time spaced data and am having a problem with Matplot lib. =20 I am plotting two datasets: one is continuous time series data (simple line chart) and the other irregular time series data. =20 The problem I have is: MatPlotLib is interpolating data for the irregular data where there is no data. =20 So if I have data from 1985 - 1989 then no data for 1990 - 1994, matplotlib is drawing a line connecting the missing data. =20 How does one plot irregular spaced time series data? Thanks Joseph =20 p.s.: if this is the wrong forum, could you let me know where to post? ```
 Re: [Matplotlib-users] iregular data set From: Rodrigues, Joseph - 2006-07-21 19:38:29 Attachments: Book1.htm ```Thanks to all who replied. I am not sure if I get this or if I am not clear on what I want. So I am attaching a simple web page of what I want vs. what I get from matplotlib. Thanks again, Joseph -----Original Message----- From: matplotlib-users-bounces@... [mailto:matplotlib-users-bounces@...] On Behalf Of Bill Dandreta Sent: Friday, July 21, 2006 3:09 PM To: matplotlib-users@... Subject: Re: [Matplotlib-users] iregular data set Rodrigues, Joseph wrote: > > I have a question (new user here): I have datasets of irregular time > spaced data and am having a problem with Matplot lib. > > I am plotting two datasets: one is continuous time series data (simple > line chart) and the other irregular time series data. > > The problem I have is: MatPlotLib is interpolating data for the > irregular data where there is no data. > > So if I have data from 1985 - 1989 then no data for 1990 - 1994, > matplotlib is drawing a line connecting the missing data. > > How does one plot irregular spaced time series data? > The way I do that is index the time data and plot against the index. 1985--0 1986--1 . . . 1989--4 1995--5 etc. Bill ------------------------------------------------------------------------ - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDE V _______________________________________________ Matplotlib-users mailing list Matplotlib-users@... https://lists.sourceforge.net/lists/listinfo/matplotlib-users ```
 Re: [Matplotlib-users] iregular data set From: PGM - 2006-07-21 20:25:57 ```Joseph, I'm a big fan of masked arrays in numpy. Your problem is typically what masked days are for: you can find an example here: http://www.scipy.org/Cookbook/Matplotlib/Plotting_values_with_masked_arrays ```
 Re: [Matplotlib-users] iregular data set From: Rodrigues, Joseph - 2006-07-21 19:40:16 Attachments: image001.gif     image002.gif ```Made a boo boo, the image is not showing so here it is again -----Original Message----- From: matplotlib-users-bounces@... [mailto:matplotlib-users-bounces@...] On Behalf Of Bill Dandreta Sent: Friday, July 21, 2006 3:09 PM To: matplotlib-users@... Subject: Re: [Matplotlib-users] iregular data set Rodrigues, Joseph wrote: > > I have a question (new user here): I have datasets of irregular time > spaced data and am having a problem with Matplot lib. > > I am plotting two datasets: one is continuous time series data (simple > line chart) and the other irregular time series data. > > The problem I have is: MatPlotLib is interpolating data for the > irregular data where there is no data. > > So if I have data from 1985 - 1989 then no data for 1990 - 1994, > matplotlib is drawing a line connecting the missing data. > > How does one plot irregular spaced time series data? > The way I do that is index the time data and plot against the index. 1985--0 1986--1 . . . 1989--4 1995--5 etc. Bill ------------------------------------------------------------------------ - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDE V _______________________________________________ Matplotlib-users mailing list Matplotlib-users@... https://lists.sourceforge.net/lists/listinfo/matplotlib-users ```
 Re: [Matplotlib-users] iregular data set From: Louis Pecora - 2006-07-21 19:48:41 ```Rodrigues, Joseph wrote: > Made a boo boo, the image is not showing so here it is again > > > -----Original Message----- > From: matplotlib-users-bounces@... > [mailto:matplotlib-users-bounces@...] On Behalf Of > Bill Dandreta > Sent: Friday, July 21, 2006 3:09 PM > To: matplotlib-users@... > Subject: Re: [Matplotlib-users] iregular data set > > Rodrigues, Joseph wrote: > >> I have a question (new user here): I have datasets of irregular time >> spaced data and am having a problem with Matplot lib. >> >> I am plotting two datasets: one is continuous time series data (simple >> line chart) and the other irregular time series data. >> >> The problem I have is: MatPlotLib is interpolating data for the >> irregular data where there is no data. >> >> So if I have data from 1985 - 1989 then no data for 1990 - 1994, >> matplotlib is drawing a line connecting the missing data. >> >> How does one plot irregular spaced time series data? >> >> From what I see matplotlib is just connecting points. Just because your x values have what you think are gaps, matplotlib doesn't know that. I assume your two calls to plot use the x and y values for each plot. Matplotlib will connect points that are sequential no matter what the x values are. There may be ways to assign the y values as NANs for those "missing" x values. -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pecora@... ```
 Re: [Matplotlib-users] iregular data set From: Rodrigues, Joseph - 2006-07-24 11:25:00 ```Thank you very much, you are a lifesaver. I took your advice and found a working example on the internet http://www.scipy.org/Cookbook/Matplotlib/Plotting_values_with_masked_arr ays (saves an image as png when run) Made some minor modifications and it worked perfectly. Thank you very much. Joseph -----Original Message----- From: Richard Albright [mailto:ralbright@...]=20 Sent: Sunday, July 23, 2006 12:46 PM To: Rodrigues, Joseph Cc: matplotlib-users@... Subject: Re: [Matplotlib-users] iregular data set You want to use matplotlib.numerix and use a masked array On Fri, 2006-07-21 at 14:24 -0400, Rodrigues, Joseph wrote: > I have a question (new user here): I have datasets of irregular time > spaced data and am having a problem with Matplot lib. >=20 > =20 >=20 > I am plotting two datasets: one is continuous time series data (simple > line chart) and the other irregular time series data. >=20 > =20 >=20 > The problem I have is: MatPlotLib is interpolating data for the > irregular data where there is no data. >=20 > =20 >=20 > So if I have data from 1985 - 1989 then no data for 1990 - 1994, > matplotlib is drawing a line connecting the missing data. >=20 > =20 >=20 > How does one plot irregular spaced time series data? >=20 > Thanks >=20 > Joseph >=20 > =20 >=20 > p.s.: if this is the wrong forum, could you let me know where to post? >=20 >=20 > ------------------------------------------------------------------------ - > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDE V > _______________________________________________ Matplotlib-users mailing list Matplotlib-users@... https://lists.sourceforge.net/lists/listinfo/matplotlib-users --=20 Rick Albright Senior Quantitvative Analyst Indie Research, LLC 254 Witherspoon Street Princeton, NJ 08542 (609)497-1030 ralbright@... ```
 Re: [Matplotlib-users] iregular data set From: John Hunter - 2006-07-21 19:06:51 ```>>>>> "Rodrigues," == Rodrigues, Joseph writes: Rodrigues> Yes, I am plotting two lines and am using two plots, Rodrigues> the two lines plots just fine in different colors, Rodrigues> however, one line is continuous from 1983 - 1995 and Rodrigues> the other dataset has irregular data points along the Rodrigues> same period of time. So I should see a continuous Rodrigues> line for the first data set and I should see a broken Rodrigues> line only where there is data for the second. Rodrigues> Matplotlib is joining the broken points and forces Rodrigues> both datasets to appear as continuous. matplotlib doesn't make any assumptions about whether data is continuous or not. It only knows about points and line styles. If you want a set of points to be connected, use a linestyle like '-' (solid line) or '--' (dashed line) plot(x, y, '-') if you don't want the points to be connected, use a marker like 'o' for circles and 's' for squares plot(x, y, 's') You will need to extract the subsets of the data that you want connected yourself. JDH ```