Re: [Matplotlib-users] x axis non-uniform labeling (KURT PETERS)

2013-09-30 Thread KURT PETERS
That doesn't seem to fix it.  What I'm expecting is at the top, 28 should 
correspond to the value -2.  Instead it puts a 30 there.
Kurt
 
Date: Mon, 30 Sep 2013 16:20:50 -0700
Subject: Re: [Matplotlib-users] x axis non-uniform labeling (KURT PETERS)
From: pmhob...@gmail.com
To: petersk...@msn.com
CC: matplotlib-users@lists.sourceforge.net



On Mon, Sep 30, 2013 at 1:43 PM, KURT PETERS  wrote:




I'm including the code below to demonstrate the problem.  The top should have 
simtimedata (0 through 28) labeling the points.  As you can see, MATPLOTLIB 
just distributes those values evenly instead of assigning them properly.

Any ideas?
 
#!/usr/bin/env python
import numpy as np
from matplotlib import rc
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import re
from matplotlib.ticker import EngFormatter

xdat=np.arange(1,11)
simtimedata = np.array([0, 1, 5, 9, 13, 18, 21, 24, 25, 28])
idatanp = np.array([-1,0, 1, 2, 3, 2, 1, 0, -1, -2])
print idatanp.shape
print simtimedata.shape
print xdat.shape
fig = plt.figure()


ax1 = fig.add_subplot(211)
ax1.plot(xdat,idatanp)
ax2 = fig.add_subplot(212)
#ax1.plot(x1, x1,'b--')
ax3 = ax2.twiny()
ax2.plot(xdat, idatanp.real,'k-o')
ax3.plot(simtimedata, idatanp,'k--',alpha=0)

ax2.set_title("time domain")
ax2.grid(True)
plt.show()

> 
> I'm trying to find a glitch in an FPGA simulation.  The data stored in a file 
> is:
> (simulation time, y)
>  
> In reality, if I plot that I get large gaps because the simulation time 
> continues and data is only output periodically.  In other words simulation 
> time is not continuous.  I'd like to view the data without the gaps, but with 
> simulation time annotating the x-axis so I can determine where the glitch 
> occurs.  

> I've tried a variety of things:
> #ax1.plot(x1, x1,'b--')
> #ax3 = ax2.twiny()
> ax2.set_xticklabels(simtimedata, fontdict=None, minor=False, rotation = 45)
> ax2.plot( idatanp.real,'k--',idatanp.imag,'g.-')

> #ax2.plot(xdat, idatanp.real,'k--',xdat,idatanp.imag,'g.-')
> #ax3.plot(simtimedata, idatanp.real,'k--',alpha=0)
>  
> but cannot get the axis to both show the data all together AND show where the 
> glitch occurs.  I thought the twiny might help to put another x axis up so I 
> could plot the data first with the x axis incrementing based on when the data 
> is read in, and then trying to place labels showing simulation time.

>  
> Does anyone have any ideas how I could do this?
> Kurt

Kurt, 
You need to show ax3's xticklabels somewhere. Like this:
import numpy as npfrom matplotlib import rcimport matplotlib.pyplot as 
pltimport matplotlib.mlab as mlabimport refrom matplotlib.ticker import 
EngFormatter
xdat=np.arange(1,11)simtimedata = np.array([0, 1, 5, 9, 13, 18, 21, 24, 25, 
28])idatanp = np.array([-1,0, 1, 2, 3, 2, 1, 0, -1, -2])

fig = plt.figure()
ax1 = fig.add_subplot(211)ax1.plot(xdat,idatanp)
ax2 = fig.add_subplot(212)ax3 = ax2.twiny()
ax2.plot(xdat, idatanp.real,'k-o')
ax3.plot(simtimedata, idatanp,'k--',alpha=0)
 #  show ax3's xticklabels
ax3.xaxis.tick_top()  ax2.set_title("time domain")ax2.grid(True)
fig.tight_layout()
  --
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] datestr2num of year and month fails for February on September 30

2013-09-30 Thread Eric Firing
On 2013/09/30 3:45 AM, Mark Bakker wrote:
> The design of the function datestr2num, unfortunately, has an undesired
> side-effect.
> Today (September 30) I cannot convert monthly data, as February doesn't
> have 30 days.
> Conversion of:
> datestr2num('2000-02')
> Gives an error:
> ValueError: day is out of range for month
>
> Should I file a bug report or a feature request?

I would classify it as a bug resulting from a bad default in dateutil.

Eric

>
> Thanks,
>
> Mark
>
>
>
> On Thu, Sep 19, 2013 at 11:38 PM, Goyo  > wrote:
>
> 2013/9/19 Mark Bakker  >:
>  > Hello List,
>  >
>  > When I use datestr2num('2010-05') it nicely converts that to
> a number
>  > representing the date.
>  > When I convert that number back with num2date, it turns out
> it sets the day
>  > to the 19th of the month. The dime is 0:00:00.
>  > Any reason it is set to the 19th instead of the first?
>  > Maybe because today it the 19th, or is that just a coincidence?
>
> datestr2num calls dateutil.parser.parse, which by default uses the
> current date at 00:00:00 for missing fields. The dateutil function
> also can use a "default" argument to change this bahavoir but it is
> not available in datestr2num.
>
> 
> http://labix.org/python-dateutil#head-a23e8ae0a661d77b89dfb3476f85b26f0b30349c
>
> Goyo
>
>
>
>
>
> --
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
>
>
>
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] x axis non-uniform labeling (KURT PETERS)

2013-09-30 Thread Paul Hobson
On Mon, Sep 30, 2013 at 1:43 PM, KURT PETERS  wrote:

> I'm including the code below to demonstrate the problem.  The top should
> have simtimedata (0 through 28) labeling the points.  As you can see,
> MATPLOTLIB just distributes those values evenly instead of assigning them
> properly.
> Any ideas?
>
> #!/usr/bin/env python
> import numpy as np
> from matplotlib import rc
> import matplotlib.pyplot as plt
> import matplotlib.mlab as mlab
> import re
> from matplotlib.ticker import EngFormatter
> xdat=np.arange(1,11)
> simtimedata = np.array([0, 1, 5, 9, 13, 18, 21, 24, 25, 28])
> idatanp = np.array([-1,0, 1, 2, 3, 2, 1, 0, -1, -2])
> print idatanp.shape
> print simtimedata.shape
> print xdat.shape
> fig = plt.figure()
>
> ax1 = fig.add_subplot(211)
> ax1.plot(xdat,idatanp)
> ax2 = fig.add_subplot(212)
> #ax1.plot(x1, x1,'b--')
> ax3 = ax2.twiny()
> ax2.plot(xdat, idatanp.real,'k-o')
> ax3.plot(simtimedata, idatanp,'k--',alpha=0)
> ax2.set_title("time domain")
> ax2.grid(True)
> plt.show()
>
> >
> > I'm trying to find a glitch in an FPGA simulation. The data stored in a
> file is:
> > (simulation time, y)
> >
> > In reality, if I plot that I get large gaps because the simulation time
> continues and data is only output periodically. In other words simulation
> time is not continuous. I'd like to view the data without the gaps, but
> with simulation time annotating the x-axis so I can determine where the
> glitch occurs.
> > I've tried a variety of things:
> > #ax1.plot(x1, x1,'b--')
> > #ax3 = ax2.twiny()
> > ax2.set_xticklabels(simtimedata, fontdict=None, minor=False, rotation =
> 45)
> > ax2.plot( idatanp.real,'k--',idatanp.imag,'g.-')
> > #ax2.plot(xdat, idatanp.real,'k--',xdat,idatanp.imag,'g.-')
> > #ax3.plot(simtimedata, idatanp.real,'k--',alpha=0)
> >
> > but cannot get the axis to both show the data all together AND show
> where the glitch occurs. I thought the twiny might help to put another x
> axis up so I could plot the data first with the x axis incrementing based
> on when the data is read in, and then trying to place labels showing
> simulation time.
> >
> > Does anyone have any ideas how I could do this?
> > Kurt
>

Kurt,

You need to show ax3's xticklabels somewhere. Like this:
import numpy as np
from matplotlib import rc
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import re
from matplotlib.ticker import EngFormatter
xdat=np.arange(1,11)
simtimedata = np.array([0, 1, 5, 9, 13, 18, 21, 24, 25, 28])
idatanp = np.array([-1,0, 1, 2, 3, 2, 1, 0, -1, -2])


fig = plt.figure()
ax1 = fig.add_subplot(211)
ax1.plot(xdat,idatanp)

ax2 = fig.add_subplot(212)
ax3 = ax2.twiny()

ax2.plot(xdat, idatanp.real,'k-o')
ax3.plot(simtimedata, idatanp,'k--',alpha=0)

 #  show ax3's xticklabels
ax3.xaxis.tick_top()
ax2.set_title("time domain")
ax2.grid(True)
fig.tight_layout()
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] x axis non-uniform labeling (KURT PETERS)

2013-09-30 Thread KURT PETERS
I'm including the code below to demonstrate the problem.  The top should have 
simtimedata (0 through 28) labeling the points.  As you can see, MATPLOTLIB 
just distributes those values evenly instead of assigning them properly.
Any ideas?
 
#!/usr/bin/env python
import numpy as np
from matplotlib import rc
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import re
from matplotlib.ticker import EngFormatter
xdat=np.arange(1,11)
simtimedata = np.array([0, 1, 5, 9, 13, 18, 21, 24, 25, 28])
idatanp = np.array([-1,0, 1, 2, 3, 2, 1, 0, -1, -2])
print idatanp.shape
print simtimedata.shape
print xdat.shape
fig = plt.figure()

ax1 = fig.add_subplot(211)
ax1.plot(xdat,idatanp)
ax2 = fig.add_subplot(212)
#ax1.plot(x1, x1,'b--')
ax3 = ax2.twiny()
ax2.plot(xdat, idatanp.real,'k-o')
ax3.plot(simtimedata, idatanp,'k--',alpha=0)
ax2.set_title("time domain")
ax2.grid(True)
plt.show()

> 
> I'm trying to find a glitch in an FPGA simulation.  The data stored in a file 
> is:
> (simulation time, y)
>  
> In reality, if I plot that I get large gaps because the simulation time 
> continues and data is only output periodically.  In other words simulation 
> time is not continuous.  I'd like to view the data without the gaps, but with 
> simulation time annotating the x-axis so I can determine where the glitch 
> occurs.  
> I've tried a variety of things:
> #ax1.plot(x1, x1,'b--')
> #ax3 = ax2.twiny()
> ax2.set_xticklabels(simtimedata, fontdict=None, minor=False, rotation = 45)
> ax2.plot( idatanp.real,'k--',idatanp.imag,'g.-')
> #ax2.plot(xdat, idatanp.real,'k--',xdat,idatanp.imag,'g.-')
> #ax3.plot(simtimedata, idatanp.real,'k--',alpha=0)
>  
> but cannot get the axis to both show the data all together AND show where the 
> glitch occurs.  I thought the twiny might help to put another x axis up so I 
> could plot the data first with the x axis incrementing based on when the data 
> is read in, and then trying to place labels showing simulation time.
>  
> Does anyone have any ideas how I could do this?
> Kurt

  --
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] datestr2num of year and month fails for February on September 30

2013-09-30 Thread Mark Bakker
The design of the function datestr2num, unfortunately, has an undesired
side-effect.
Today (September 30) I cannot convert monthly data, as February doesn't
have 30 days.
Conversion of:
datestr2num('2000-02')
Gives an error:
ValueError: day is out of range for month

Should I file a bug report or a feature request?

Thanks,

Mark


>
> On Thu, Sep 19, 2013 at 11:38 PM, Goyo  wrote:
>
>> 2013/9/19 Mark Bakker :
>> > Hello List,
>> >
>> > When I use datestr2num('2010-05') it nicely converts that to a number
>> > representing the date.
>> > When I convert that number back with num2date, it turns out it sets the
>> day
>> > to the 19th of the month. The dime is 0:00:00.
>> > Any reason it is set to the 19th instead of the first?
>> > Maybe because today it the 19th, or is that just a coincidence?
>>
>> datestr2num calls dateutil.parser.parse, which by default uses the
>> current date at 00:00:00 for missing fields. The dateutil function
>> also can use a "default" argument to change this bahavoir but it is
>> not available in datestr2num.
>>
>>
>> http://labix.org/python-dateutil#head-a23e8ae0a661d77b89dfb3476f85b26f0b30349c
>>
>> Goyo
>>
>
>
--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users