|
From: Grant E. <gr...@vi...> - 2007-04-09 16:08:14
|
I'm following the 3D plotting examples I found at http://www.scipy.org/Cookbook/Matplotlib/mplot3D The problem is that my program hangs when I call pylab.show(), it never returns: my program hangs. How do I show a 3D plot without hanging my program? -- Grant Edwards grante Yow! Is this where people at are HOT and NICE and they visi.com give you TOAST for FREE?? |
|
From: Lou P. <lou...@ya...> - 2007-04-09 16:19:59
|
I assume you mean the first example, the wire frame
(see below). It works for me. No problems. When
pylab (matplotlib) plots it does so in a window
associated with a Python process that is separate from
the terminal (I assume you are using a terminal). You
might need to bring that process window to the
foreground.
Here's the code that worked for me:
from numpy import *
import pylab as p
import matplotlib.axes3d as p3
# u and v are parametric variables.
# u is an array from 0 to 2*pi, with 100 elements
u=r_[0:2*pi:100j]
# v is an array from 0 to 2*pi, with 100 elements
v=r_[0:pi:100j]
# x, y, and z are the coordinates of the points for
plotting
# each is arranged in a 100x100 array
x=10*outer(cos(u),sin(v))
y=10*outer(sin(u),sin(v))
z=10*outer(ones(size(u)),cos(v))
fig=p.figure()
ax = p3.Axes3D(fig)
ax.plot_wireframe(x,y,z)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
p.show()
--- Grant Edwards <gr...@vi...> wrote:
> I'm following the 3D plotting examples I found at
>
> http://www.scipy.org/Cookbook/Matplotlib/mplot3D
>
> The problem is that my program hangs when I call
> pylab.show(),
> it never returns: my program hangs.
>
> How do I show a 3D plot without hanging my program?
>
> --
> Grant Edwards grante
-- Lou Pecora, my views are my own.
---------------
"I knew I was going to take the wrong train, so I left early."
--Yogi Berra
____________________________________________________________________________________
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
http://games.yahoo.com/games/front
|
|
From: Utkarsh U. <mus...@gm...> - 2007-04-09 17:52:15
|
Hi,
The examples worked for me too, and I am using IDLE on Windows. And
isn't the program supposed to return control to the terminal even if
the Graph Window is in the background?
There may be something wrong. Can you post the exact code that you are
trying to run and the version numbers? I am not an expert, but it may
help.
--musically_ut
On 4/9/07, Lou Pecora <lou...@ya...> wrote:
> I assume you mean the first example, the wire frame
> (see below). It works for me. No problems. When
> pylab (matplotlib) plots it does so in a window
> associated with a Python process that is separate from
> the terminal (I assume you are using a terminal). You
> might need to bring that process window to the
> foreground.
>
> Here's the code that worked for me:
>
> from numpy import *
> import pylab as p
> import matplotlib.axes3d as p3
>
> # u and v are parametric variables.
> # u is an array from 0 to 2*pi, with 100 elements
> u=r_[0:2*pi:100j]
> # v is an array from 0 to 2*pi, with 100 elements
> v=r_[0:pi:100j]
>
> # x, y, and z are the coordinates of the points for
> plotting
> # each is arranged in a 100x100 array
> x=10*outer(cos(u),sin(v))
> y=10*outer(sin(u),sin(v))
> z=10*outer(ones(size(u)),cos(v))
>
> fig=p.figure()
> ax = p3.Axes3D(fig)
> ax.plot_wireframe(x,y,z)
> ax.set_xlabel('X')
> ax.set_ylabel('Y')
> ax.set_zlabel('Z')
> p.show()
>
> --- Grant Edwards <gr...@vi...> wrote:
>
> > I'm following the 3D plotting examples I found at
> >
> > http://www.scipy.org/Cookbook/Matplotlib/mplot3D
> >
> > The problem is that my program hangs when I call
> > pylab.show(),
> > it never returns: my program hangs.
> >
> > How do I show a 3D plot without hanging my program?
> >
> > --
> > Grant Edwards grante
>
>
>
> -- Lou Pecora, my views are my own.
> ---------------
> "I knew I was going to take the wrong train, so I left early."
> --Yogi Berra
>
>
>
> ____________________________________________________________________________________
> Bored stiff? Loosen up...
> Download and play hundreds of games for free on Yahoo! Games.
> http://games.yahoo.com/games/front
>
> -------------------------------------------------------------------------
> 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=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
Never trust a spiritual leader who cannot dance. ~Mr. Miyagi, The Next
Karate Kid
|
|
From: Grant E. <gr...@vi...> - 2007-04-09 18:17:16
|
On 2007-04-09, Lou Pecora <lou...@ya...> wrote:
> I assume you mean the first example, the wire frame (see
> below). It works for me.
I've tried that code as well, and p.show() doesn't return until
the window is closed. If I use code like that in a python
program, the program becomes non-responsive until the plot
window is closed.
I've switched to using wxmpl to embed figure in a wxWidgets
panel. That almost works -- except I loose the ability for the
user to rotate/zoom using the mouse.
> No problems. When pylab (matplotlib) plots it does so in a
> window associated with a Python process that is separate from
> the terminal (I assume you are using a terminal).
I'm not sure what you mean by "using a terminal". I'm running
my python app from the command line in a terminal emulator
window.
--
Grant Edwards grante Yow! Hey, I LIKE that
at POINT!!
visi.com
|
|
From: Lou P. <lou...@ya...> - 2007-04-09 18:51:32
|
Some answers: --- Grant Edwards <gr...@vi...> wrote: > On 2007-04-09, Lou Pecora <lou...@ya...> > wrote: > > > I assume you mean the first example, the wire > frame (see > > below). It works for me. > > I've tried that code as well, and p.show() doesn't > return until > the window is closed. If I use code like that in a > python > program, the program becomes non-responsive until > the plot > window is closed. That is how pylab works. The program has to respond to events in the plot window and cannot respond to the command line. > I've switched to using wxmpl to embed figure in a > wxWidgets > panel. That almost works -- except I loose the > ability for the > user to rotate/zoom using the mouse. I have not tried this approach very much. I'm sorry, but I can't think of a way to retain the rotate/zoom. Perhaps others can offer help. > > No problems. When pylab (matplotlib) plots it > does so in a > > window associated with a Python process that is > separate from > > the terminal (I assume you are using a terminal). > > I'm not sure what you mean by "using a terminal". > I'm running > my python app from the command line in a terminal > emulator > window. Yes, that is what I meant by using a terminal. -- Lou Pecora, my views are my own. --------------- "I knew I was going to take the wrong train, so I left early." --Yogi Berra ____________________________________________________________________________________ Need Mail bonding? Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users. http://answers.yahoo.com/dir/?link=list&sid=396546091 |
|
From: Suresh P. <sto...@ya...> - 2007-04-09 18:39:40
|
I get this behaviour as well, but only on first usage of show(). However, after that there is no problem. The default is to start off with interactive mode off, but the first usage of show() turns it on. So I would guess that the problem is that with interactive mode turned off, the figure window is not returning. On Mon, 9 Apr 2007, Grant Edwards wrote: > I've tried that code as well, and p.show() doesn't return until > the window is closed. If I use code like that in a python > program, the program becomes non-responsive until the plot > window is closed. |
|
From: Ken M. <mc...@ii...> - 2007-04-09 20:09:12
|
On Apr 9, 2007, at 1:16 PM, Grant Edwards wrote: > > I've switched to using wxmpl to embed figure in a wxWidgets > panel. That almost works -- except I loose the ability for the > user to rotate/zoom using the mouse. I'm afraid that the current version of WxMpl doesn't play nicely with matplotlib's event system. I hope to integrate the two event models so stuff like 3D rotations work. Unfortunately that probably won't be happening for some time yet. Ken |
|
From: Iyer <mas...@ya...> - 2007-04-10 13:06:44
|
I think this is a trivial question..
If there are a set of data points being plotted in a
subplot, say 0 to 1000 points; the subplot displays
the ticks as 0 to 1000 points and it is desired to
"translate" those points to 0 t0 250 points on the
subplot display - with point 0 mapping to point 0,
point 250 mapping to point 2 and so on, what could be
the best way to do this ?
Just curious,
thanks,
iyer
____________________________________________________________________________________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/
|
|
From: Antonio G. <Ant...@ki...> - 2007-04-10 13:23:31
|
Not sure if I understand, but I think this is what you want to do: y = rand(1000) # your 1000 random points x = linspace(0, 250, y.size) plot(x,y) /A Iyer wrote: > I think this is a trivial question.. > > If there are a set of data points being plotted in a > subplot, say 0 to 1000 points; the subplot displays > the ticks as 0 to 1000 points and it is desired to > "translate" those points to 0 t0 250 points on the > subplot display - with point 0 mapping to point 0, > point 250 mapping to point 2 and so on, what could be > the best way to do this ? > > Just curious, > thanks, > iyer > > > > > > > > ____________________________________________________________________________________ > Never miss an email again! > Yahoo! Toolbar alerts you the instant new Mail arrives. > http://tools.search.yahoo.com/toolbar/features/mail/ > > ------------------------------------------------------------------------- > 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=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Iyer <mas...@ya...> - 2007-04-10 13:40:48
|
Thanx for the response.. I'd like to avoid the pylab interface... linspace is good. assume you have 1000 points of data and you'd like the ticks to display from 0 to 4, since the 1000 points of data were sampled at 250 Hz. any "non-pylab" ideas ? Indexlocator? -iyer --- Antonio Gonzalez <Ant...@ki...> wrote: > Not sure if I understand, but I think this is what > you want to do: > > y = rand(1000) # your 1000 random points > x = linspace(0, 250, y.size) > plot(x,y) > > /A > > > Iyer wrote: > > I think this is a trivial question.. > > > > If there are a set of data points being plotted in > a > > subplot, say 0 to 1000 points; the subplot > displays > > the ticks as 0 to 1000 points and it is desired to > > "translate" those points to 0 t0 250 points on the > > subplot display - with point 0 mapping to point 0, > > point 250 mapping to point 2 and so on, what could > be > > the best way to do this ? > > > > Just curious, > > thanks, > > iyer > > > > > > > > > > > > > > > > > ____________________________________________________________________________________ > > Never miss an email again! > > Yahoo! Toolbar alerts you the instant new Mail > arrives. > > > http://tools.search.yahoo.com/toolbar/features/mail/ > > > > > ------------------------------------------------------------------------- > > 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=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ____________________________________________________________________________________ Sucker-punch spam with award-winning protection. Try the free Yahoo! Mail Beta. http://advision.webevents.yahoo.com/mailbeta/features_spam.html |
|
From: John H. <jd...@gm...> - 2007-04-10 14:48:03
|
On 4/10/07, Iyer <mas...@ya...> wrote: > I'd like to avoid the pylab interface... > linspace is good. from matplotlib.mlab import linspace But linspace may not be what you want. Probably better: In [1]: Fs = 4. # sampling at 4Hz In [2]: dt = 1./Fs In [3]: import numpy In [4]: ind = numpy.arange(1000.) # the sample number In [5]: t = ind*dt # the sample times In [6]: t[0] Out[6]: 0.0 In [7]: t[1] Out[7]: 0.25 linspace gives a slightly different answer, because it includes the endpoint. Sometimes this is what you want, sometimes not. |
|
From: Iyer <mas...@ya...> - 2007-04-10 15:06:59
|
I apologize if I haven't been sufficiently clear.
While your suggestion picks out the samples from the
sample set, and discards other samples - what I was
looking at --
when I plot a sample set, of say - 1000 points, the
xticks shows up as 0 to 1000 points on the plot.
I was wondering if there could be a way to translate
the xtick display to that of seconds, if the sampling
frequency is 250 Hz, the plot would still display the
original data set, but with different xticks -- for
e.g. it would display xticks as 0 to 4 seconds rather
than 0 to 1000 points.. hence is there a good way to
"translate ticks" ?
-iyer
--- John Hunter <jd...@gm...> wrote:
> On 4/10/07, Iyer <mas...@ya...> wrote:
> > I'd like to avoid the pylab interface...
> > linspace is good.
>
> from matplotlib.mlab import linspace
>
> But linspace may not be what you want. Probably
> better:
>
> In [1]: Fs = 4. # sampling at 4Hz
>
> In [2]: dt = 1./Fs
>
> In [3]: import numpy
>
> In [4]: ind = numpy.arange(1000.) # the sample
> number
>
> In [5]: t = ind*dt # the sample times
>
> In [6]: t[0]
> Out[6]: 0.0
>
> In [7]: t[1]
> Out[7]: 0.25
>
>
> linspace gives a slightly different answer, because
> it includes the
> endpoint. Sometimes this is what you want,
> sometimes not.
>
____________________________________________________________________________________
The fish are biting.
Get more visitors on your site using Yahoo! Search Marketing.
http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php
|
|
From: John H. <jd...@gm...> - 2007-04-10 15:11:32
|
On 4/10/07, Iyer <mas...@ya...> wrote: > I apologize if I haven't been sufficiently clear. > > While your suggestion picks out the samples from the > sample set, and discards other samples - what I was > looking at -- > > when I plot a sample set, of say - 1000 points, the > xticks shows up as 0 to 1000 points on the plot. > > I was wondering if there could be a way to translate > the xtick display to that of seconds, if the sampling > frequency is 250 Hz, the plot would still display the > original data set, but with different xticks -- for > e.g. it would display xticks as 0 to 4 seconds rather > than 0 to 1000 points.. hence is there a good way to > "translate ticks" ? Yes, you can certainly do this, but what we are suggesting is that it makes more sense to simply scale your data before plotting. Is there a reason you don't want to do this ax.plot(ind*dt, y) The index locator JDH |
|
From: Iyer <mas...@ya...> - 2007-04-10 15:20:52
|
Wouldn't it make sense to simply change the xticks to
reflect the time instead of the number of data points
?
Like, if we needed to display 0 t0 1000 points over a
period of time, wouldn't it be nice to translate the
xticks to reflect the period of time ?
Would you suggest using IndexLocator in that sense ?
-iyer
> hence is there a good way
> to
> > "translate ticks" ?
>
> Yes, you can certainly do this, but what we are
> suggesting is that it
> makes more sense to simply scale your data before
> plotting. Is there
> a reason you don't want to do this
>
> ax.plot(ind*dt, y)
>
> The index locator
>
> JDH
>
____________________________________________________________________________________
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/
|
|
From: John H. <jd...@gm...> - 2007-04-10 15:35:05
|
On 4/10/07, Iyer <mas...@ya...> wrote: > > Wouldn't it make sense to simply change the xticks to > reflect the time instead of the number of data points No > Like, if we needed to display 0 t0 1000 points over a > period of time, wouldn't it be nice to translate the > xticks to reflect the period of time ? No > Would you suggest using IndexLocator in that sense ? No |
|
From: John H. <jd...@gm...> - 2007-04-10 15:43:39
|
On 4/10/07, John Hunter <jd...@gm...> wrote: > On 4/10/07, Iyer <mas...@ya...> wrote: > > I apologize if I haven't been sufficiently clear. > > > > While your suggestion picks out the samples from the > > sample set, and discards other samples - what I was > > looking at -- My suggestion does not "discard other samples", so you may not be understanding what I am saying. Perhaps you can try the suggested code and see if it does what you want. My example plots all the samples; it simply scales the xaxis to represent time and not sample number. |
|
From: Iyer <mas...@ya...> - 2007-04-10 17:23:51
|
It is not what I need.. http://matplotlib.sourceforge.net/matplotlib.axes.html The plot method (plot(self, *args, **kwargs)) accepts only x,y pairs, in ax.plot(ind*dt, y) -- the x parameter is ind*dt - the sample times, but the data between the sample points is lost. IMHO, the likely way to prevent loss of sampled data points is changing the ticks, isn't that possible to change the ticks, while keeping the data as it is -- plotted as if it were for a number of data points. -iyer --- John Hunter <jd...@gm...> wrote: > On 4/10/07, John Hunter <jd...@gm...> wrote: > > On 4/10/07, Iyer <mas...@ya...> wrote: > > > I apologize if I haven't been sufficiently > clear. > > > > > > While your suggestion picks out the samples from > the > > > sample set, and discards other samples - what I > was > > > looking at -- > > My suggestion does not "discard other samples", so > you may not be > understanding what I am saying. Perhaps you can try > the suggested > code and see if it does what you want. My example > plots all the > samples; it simply scales the xaxis to represent > time and not sample > number. > ____________________________________________________________________________________ Looking for earth-friendly autos? Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center. http://autos.yahoo.com/green_center/ |
|
From: Eric F. <ef...@ha...> - 2007-04-10 17:43:55
|
There seems to be a huge misunderstanding here, and I am not sure what it is, but what you need to do is run examples and experiment with variations until you have some inkling of what mpl is actually doing. Start with http://matplotlib.sourceforge.net/tutorial.html. Please note that the ticks are simply labeled locations--they have no effect on what data are plotted. When you do ax.plot(ind*dt, y), absolutely *nothing* is lost; every value of y in your array is plotted. mpl is plotting (x,y) pairs--all of them--and labeling the axes accordingly. To see what is being plotted, you can use plot(x,y,'ro'), for example, to plot each point as a red circle. Experiment with this. Don't worry right now about avoiding the pylab interface; take advantage of its simplicity to get the most basic plotting concepts straightened out via quick experimentation. Use the gui zoom button to see how axis labeling works. Make your own simple examples; plot random points, plot sin waves. Eric Iyer wrote: > It is not what I need.. > > http://matplotlib.sourceforge.net/matplotlib.axes.html > > The plot method (plot(self, *args, **kwargs)) accepts > only x,y pairs, in ax.plot(ind*dt, y) -- the x > parameter is ind*dt - the sample times, but the data > between the sample points is lost. IMHO, the likely > way to prevent loss of sampled data points is changing > the ticks, isn't that possible to change the ticks, > while keeping the data as it is -- plotted as if it > were for a number of data points. > > -iyer > > > > > --- John Hunter <jd...@gm...> wrote: > >> On 4/10/07, John Hunter <jd...@gm...> wrote: >>> On 4/10/07, Iyer <mas...@ya...> wrote: >>>> I apologize if I haven't been sufficiently >> clear. >>>> While your suggestion picks out the samples from >> the >>>> sample set, and discards other samples - what I >> was >>>> looking at -- >> My suggestion does not "discard other samples", so >> you may not be >> understanding what I am saying. Perhaps you can try >> the suggested >> code and see if it does what you want. My example >> plots all the >> samples; it simply scales the xaxis to represent >> time and not sample >> number. >> > > > > > ____________________________________________________________________________________ > Looking for earth-friendly autos? > Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center. > http://autos.yahoo.com/green_center/ > > ------------------------------------------------------------------------- > 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=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Iyer <mas...@ya...> - 2007-04-10 21:03:09
|
With all respect, I have certainly perused the tutorials before posting the question. I'm still a newbie and I acknowledge I have miles and miles to go before I can be someone who can help out in the Matplotlib group like you guys do. The problem is simple, it is like the date examples in the Matplotlib code -- the ticks for the date examples (seconds, hours, time etc) are different from the usual ticks, which is usually the number of samples. If only someone could guide me, so that I can understand better how to "translate" the ticks from the default "number of sample" ticks to that of different ticks - say new_ticks=original_ticks/(some_constant). Right now I'm clueless, your input will help a lot in understanding Mpl. Thanks guys for your feedback and help iyer --- Eric Firing <ef...@ha...> wrote: > There seems to be a huge misunderstanding here, and > I am not sure what > it is, but what you need to do is run examples and > experiment with > variations until you have some inkling of what mpl > is actually doing. > Start with > http://matplotlib.sourceforge.net/tutorial.html. > > Please note that the ticks are simply labeled > locations--they have no > effect on what data are plotted. > > When you do ax.plot(ind*dt, y), absolutely *nothing* > is lost; every > value of y in your array is plotted. mpl is plotting > (x,y) pairs--all of > them--and labeling the axes accordingly. > > To see what is being plotted, you can use > plot(x,y,'ro'), for example, > to plot each point as a red circle. Experiment with > this. > > Don't worry right now about avoiding the pylab > interface; take advantage > of its simplicity to get the most basic plotting > concepts straightened > out via quick experimentation. Use the gui zoom > button to see how axis > labeling works. Make your own simple examples; plot > random points, plot > sin waves. > > Eric > > Iyer wrote: > > It is not what I need.. > > > > > http://matplotlib.sourceforge.net/matplotlib.axes.html > > > > The plot method (plot(self, *args, **kwargs)) > accepts > > only x,y pairs, in ax.plot(ind*dt, y) -- the x > > parameter is ind*dt - the sample times, but the > data > > between the sample points is lost. IMHO, the > likely > > way to prevent loss of sampled data points is > changing > > the ticks, isn't that possible to change the > ticks, > > while keeping the data as it is -- plotted as if > it > > were for a number of data points. > > > > -iyer > > > > > > > > > > --- John Hunter <jd...@gm...> wrote: > > > >> On 4/10/07, John Hunter <jd...@gm...> > wrote: > >>> On 4/10/07, Iyer <mas...@ya...> wrote: > >>>> I apologize if I haven't been sufficiently > >> clear. > >>>> While your suggestion picks out the samples > from > >> the > >>>> sample set, and discards other samples - what I > >> was > >>>> looking at -- > >> My suggestion does not "discard other samples", > so > >> you may not be > >> understanding what I am saying. Perhaps you can > try > >> the suggested > >> code and see if it does what you want. My > example > >> plots all the > >> samples; it simply scales the xaxis to represent > >> time and not sample > >> number. > >> > > > > > > > > > > > ____________________________________________________________________________________ > > Looking for earth-friendly autos? > > Browse Top Cars by "Green Rating" at Yahoo! Autos' > Green Center. > > http://autos.yahoo.com/green_center/ > > > > > ------------------------------------------------------------------------- > > 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=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > ____________________________________________________________________________________ Don't pick lemons. See all the new 2007 cars at Yahoo! Autos. http://autos.yahoo.com/new_cars.html |
|
From: John H. <jd...@gm...> - 2007-04-10 21:13:50
|
On 4/10/07, Iyer <mas...@ya...> wrote:
> If only someone could guide me, so that I can
> understand better how to "translate" the ticks from
> the default "number of sample" ticks to that of
> different ticks - say
> new_ticks=original_ticks/(some_constant). Right now
> I'm clueless, your input will help a lot in
> understanding Mpl.
OK, your persistence is admirable. You are still asking the wrong
question and applying the wrong solution, but dog-golly, you've earned
the right to do it the wrong way!
from matplotlib.ticker import FuncFormatter
def myformatter(x, pos=None):
return '%1.3f'%(x/4.)
ax = subplot(111)
ax.plot(x, y)
ax.xaxis.set_major_formatter(FuncFormatter(myformatter))
Now all your ticks are magically divided by 4.
But really, simply scaling your x input data is the way to go. If we
want to move this conversation forward, you should try instead
plot(x/4, y)
and then explain as clearly as possibly this doesn't do what you want.
|
|
From: Iyer <mas...@ya...> - 2007-05-15 00:48:31
|
Hi
I apologize for my late response, I was in the
hospital.
Thanks for the tip, the ticks are now magically
divided by a constant.
Here's some input on scaling the input data:
Say -- you have 25000 points of data. You want to
capture each and every point of data on a plot. Mpl
lists the ticks as a function of the number of data
points, which is cool. Now comes a situation where in
you want to manipulate the ticks to display - say the
time, for eg., the 100th data point came in at 1 sec,
the 200th came in at 2 sec, and so on - Is scaling the
input data the way to go ?
-iyer
--- John Hunter <jd...@gm...> wrote:
> On 4/10/07, Iyer <mas...@ya...> wrote:
>
> > If only someone could guide me, so that I can
> > understand better how to "translate" the ticks
> from
> > the default "number of sample" ticks to that of
> > different ticks - say
> > new_ticks=original_ticks/(some_constant). Right
> now
> > I'm clueless, your input will help a lot in
> > understanding Mpl.
>
>
> OK, your persistence is admirable. You are still
> asking the wrong
> question and applying the wrong solution, but
> dog-golly, you've earned
> the right to do it the wrong way!
>
> from matplotlib.ticker import FuncFormatter
>
> def myformatter(x, pos=None):
> return '%1.3f'%(x/4.)
>
> ax = subplot(111)
> ax.plot(x, y)
>
ax.xaxis.set_major_formatter(FuncFormatter(myformatter))
>
> Now all your ticks are magically divided by 4.
>
> But really, simply scaling your x input data is the
> way to go. If we
> want to move this conversation forward, you should
> try instead
>
> plot(x/4, y)
>
> and then explain as clearly as possibly this doesn't
> do what you want.
>
____________________________________________________________________________________Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
|
|
From: Iyer <mas...@ya...> - 2007-05-15 01:06:21
Attachments:
before_pan.jpg
after_pan.jpg
|
It's cool creating annotations, when the pan tool is
used , I see that the markers/annotations do not
behave in the same way as that of the plot -- i.e.,
when I pan towards the left or right, the annotations
do not disappear with the plot at the boundaries of
the subplot. The annotations continue to be displayed.
Any solution for this ?
I've attached illustrations.
-thanks
iyer
____________________________________________________________________________________Give spam the boot. Take control with tough spam protection in the all-new Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_html.html |
|
From: John H. <jd...@gm...> - 2007-05-15 02:46:27
|
On 5/14/07, Iyer <mas...@ya...> wrote: > It's cool creating annotations, when the pan tool is > used , I see that the markers/annotations do not > behave in the same way as that of the plot -- i.e., > when I pan towards the left or right, the annotations > do not disappear with the plot at the boundaries of > the subplot. The annotations continue to be displayed. This is part feature, part bug. The feature part is that you don't always want you annotation clipped -- sometimes you explicitly want the annotation outside the axes and not clipped (eg in the polar demo of examples/annotation_demo.py). The bug part is that sometimes you do want it clipped, and this is currently broken. The version you are using is different than the svn version, and thus still broken, but I just committed changes to svn to fix this, so if you want clipping you can enable it with a = ax.annotate(something, ..., clip_on=True) Again, this will only work with svn mpl (and in the next release) Thanks for the report! JDH |
|
From: <jk...@ik...> - 2007-04-11 05:11:03
|
Iyer <mas...@ya...> writes: > With all respect, I have certainly perused the > tutorials before posting the question. >From your postings it seems that you are misunderstanding some fundamental concepts, but it is not clear how. Can you write up a little piece of code showing what you are doing now, and explain how you would like the output changed? Just make up some data and plot it, and point out what is wrong about the result. As an example of how to phrase your question, here is how I would write the question I thought you were trying to communicate a few emails ago: ---------------------------------------------------------------------- The following script makes an otherwise good plot, but I want the x-axis to go from 0 to 1, not 0 to 10. How do I do this? x = arange(0,10,0.5) y = sin(x) plot(x,y) ---------------------------------------------------------------------- The best answer to *that* question, which you got from John Hunter, is to change the script to the following: x = arange(0,10,0.5) y = sin(x) dt = 1.0/10 plot(x*dt,y) Since you say that this does not solve your problem, that must not have been the question you intended to ask. Perhaps rephrasing the question using a code example would help make your point clearer. -- Jouni K. Seppänen http://www.iki.fi/jks |
|
From: Grant E. <gr...@vi...> - 2007-04-09 21:53:05
|
On 2007-04-09, Grant Edwards <gr...@vi...> wrote:
> On 2007-04-09, Lou Pecora <lou...@ya...> wrote:
>
>> I assume you mean the first example, the wire frame (see
>> below). It works for me.
>
> I've tried that code as well, and p.show() doesn't return until
> the window is closed. If I use code like that in a python
> program, the program becomes non-responsive until the plot
> window is closed.
>
> I've switched to using wxmpl to embed figure in a wxWidgets
> panel. That almost works -- except I loose the ability for the
> user to rotate/zoom using the mouse.
I think I'm going to have to switch to using gnuplot for the 3D
window. Matplotlib is just too slow. The 3D window takes about
2 seconds to plot, and whan the user rotates the image, it only
updates at about 1fps. Gnuplot does the plot pretty much
instantaneously and rotates and zooms smoothly, so that's
probably going to be the deciding factor...
--
Grant Edwards grante Yow! Is it 1974? What's
at for SUPPER? Can I spend my
visi.com COLLEGE FUND in one wild
afternoon??
|