Producing a Histogram When Bins Are Known
I have a list that already has the frequencies from 0 to 255. However, I'd like to make a histogram that has say 32 bins whose ranges are 0-7, 8-15, ... 248-255. Is it possible? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet 350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive. Web Page: <www.speckledwithstars.net/>
On Fri, Nov 27, 2009 at 12:16 AM, Wayne Watson <sierra_mtnview@sbcglobal.net> wrote:
I have a list that already has the frequencies from 0 to 255. However, I'd like to make a histogram that has say 32 bins whose ranges are 0-7, 8-15, ... 248-255. Is it possible?
If they have equal sized (width) bins, then you should be able to reshape and sum up frequ.reshape((-1,8)).sum(1) or something like this, If the bins have different interval widths, then it might be a bit trickier to do it without loop. Josef
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Wayne Watson wrote:
I have a list that already has the frequencies from 0 to 255. However, I'd like to make a histogram that has say 32 bins whose ranges are 0-7, 8-15, ... 248-255. Is it possible?
Wayne, you might find the 'numpy example list with doc' webpage quite informative... http://www.scipy.org/Numpy_Example_List_With_Doc (give it some time to load, it's pretty large...) For new users (I was one once...) it usually takes some time to find the usual suspects in numpy/scipy help and docs... This one page has really become unvaluable for me. It gives you the docstrings for numpy functions, often including some example code. If you check out the histogram() function, you'll see it takes a 'bins=' argument: bins : int or sequence of scalars, optional If `bins` is an int, it defines the number of equal-width bins in the given range (10, by default). If `bins` is a sequence, it defines the bin edges, including the rightmost edge, allowing for non-uniform bin widths. So, if your bins are known, you can pass it to numpy.histogram, either as number-of-bins (if equal width), if necessary combined with the 'range=' parameter to specify the range to divide into equal bins, or as bin edges (e.g. in your case: (0, 8, 16, ... 256) or numpy.linspace(0,256,33) which will give you this range nicely. If you don't specify the 'range=' parameter, it will check the min and max from your input data and use that as lower and upper bounds. Good luck learning numpy! :) Vincent.
Thanks. That sounds like it should help a lot. Finding meaningful examples anywhere hasn't been easy. I thought I'd look through Amazon for books on Python and scientific uses. I found almost all were written by authors outside the US, and none seemed to talk about items like matplotlib. Ezdraw or something like that was often cited. I'm definitely in a learning stage, and much of what I need is in graphics to support some data analysis that I'm doing. Glad to hear it can gather bins into groups. It would be very disappointing if such a mechanism did not exist. In the distant past, I've all too often had to write my own histogram programs for this, FORTRAN, etc. My data is from a 640x480 collection of b/w pixels, which a processor has binned from 0-255, so I don't want repeat doing a histogram on 307K data points. Vincent Schut wrote:
Wayne Watson wrote:
I have a list that already has the frequencies from 0 to 255. However, I'd like to make a histogram that has say 32 bins whose ranges are 0-7, 8-15, ... 248-255. Is it possible?
Wayne,
you might find the 'numpy example list with doc' webpage quite informative... http://www.scipy.org/Numpy_Example_List_With_Doc (give it some time to load, it's pretty large...) For new users (I was one once...) it usually takes some time to find the usual suspects in numpy/scipy help and docs... This one page has really become unvaluable for me.
It gives you the docstrings for numpy functions, often including some example code.
If you check out the histogram() function, you'll see it takes a 'bins=' argument:
bins : int or sequence of scalars, optional If `bins` is an int, it defines the number of equal-width bins in the given range (10, by default). If `bins` is a sequence, it defines the bin edges, including the rightmost edge, allowing for non-uniform bin widths.
So, if your bins are known, you can pass it to numpy.histogram, either as number-of-bins (if equal width), if necessary combined with the 'range=' parameter to specify the range to divide into equal bins, or as bin edges (e.g. in your case: (0, 8, 16, ... 256) or numpy.linspace(0,256,33) which will give you this range nicely.
If you don't specify the 'range=' parameter, it will check the min and max from your input data and use that as lower and upper bounds.
Good luck learning numpy! :)
Vincent.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet 350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive. Web Page: <www.speckledwithstars.net/>
On Fri, Nov 27, 2009 at 8:43 AM, Wayne Watson <sierra_mtnview@sbcglobal.net> wrote:
Thanks. That sounds like it should help a lot. Finding meaningful examples anywhere hasn't been easy. I thought I'd look through Amazon for books on Python and scientific uses. I found almost all were written by authors outside the US, and none seemed to talk about items like matplotlib. Ezdraw or something like that was often cited. I'm definitely in a learning stage, and much of what I need is in graphics to support some data analysis that I'm doing.
Glad to hear it can gather bins into groups. It would be very disappointing if such a mechanism did not exist. In the distant past, I've all too often had to write my own histogram programs for this, FORTRAN, etc. My data is from a 640x480 collection of b/w pixels, which a processor has binned from 0-255, so I don't want repeat doing a histogram on 307K data points.
Vincent Schut wrote:
Wayne Watson wrote:
I have a list that already has the frequencies from 0 to 255. However, I'd like to make a histogram that has say 32 bins whose ranges are 0-7, 8-15, ... 248-255. Is it possible?
Wayne,
you might find the 'numpy example list with doc' webpage quite informative... http://www.scipy.org/Numpy_Example_List_With_Doc (give it some time to load, it's pretty large...) For new users (I was one once...) it usually takes some time to find the usual suspects in numpy/scipy help and docs... This one page has really become unvaluable for me.
It gives you the docstrings for numpy functions, often including some example code.
Numpy_Example_List_With_Doc is for an older version of numpy and hasn't been kept up to date. So if your results don't match up, then the function might have changed and the official docs will have the current description. from numpy import * is not recommended anymore, it messes up the global namespace too much Besides the the example list, I found http://scipy.org/Numpy_Functions_by_Category very helpful, because it gave a better overview of which functions do similar things. In the current docs, "See Also" can be used now in a similar way. Good luck, Josef
If you check out the histogram() function, you'll see it takes a 'bins=' argument:
bins : int or sequence of scalars, optional If `bins` is an int, it defines the number of equal-width bins in the given range (10, by default). If `bins` is a sequence, it defines the bin edges, including the rightmost edge, allowing for non-uniform bin widths.
So, if your bins are known, you can pass it to numpy.histogram, either as number-of-bins (if equal width), if necessary combined with the 'range=' parameter to specify the range to divide into equal bins, or as bin edges (e.g. in your case: (0, 8, 16, ... 256) or numpy.linspace(0,256,33) which will give you this range nicely.
If you don't specify the 'range=' parameter, it will check the min and max from your input data and use that as lower and upper bounds.
Good luck learning numpy! :)
Vincent.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
It's good to have some extra references for NumPy. Actually, it looks like exercising histogram in NunPy has gotten me past the difficulties with hist in matplotlib. I Is there a matplotlib or Pylab mailing list. It uses hist and looks very much like histogram, but has some parameters that I need to understand better. . -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet 350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive. Web Page: <www.speckledwithstars.net/>
On Fri, Nov 27, 2009 at 12:14 PM, Wayne Watson <sierra_mtnview@sbcglobal.net> wrote:
It's good to have some extra references for NumPy.
Actually, it looks like exercising histogram in NunPy has gotten me past the difficulties with hist in matplotlib. I Is there a matplotlib or Pylab mailing list. It uses hist and looks very much like histogram, but has some parameters that I need to understand better. .
I don't know if this has come up yet in your questions, but matplotlib has a mailing list that can be found here: http://matplotlib.sourceforge.net/ There are also *numerous* examples that I have found indispensable in getting over the initial learning curve if you click on examples from their sourceforge docs. It is my (quite possibly incorrect) understanding that matplotlib.pylab has many of the same functions of numpy (and leverages numpy in most(?) instances when possible). I think that is why it is recommended that for numpy users who only wish to use the plotting functionality of matplotlib that you do from matplotlib import pyplot as plt # or whatever In any case, have a look through the examples in the matplotlib docs. There may also be more examples installed with matplotlib itself. I don't know if they're all in the online docs. Skipper
Wayne Watson wrote:
Yes, I'm just beginning to deal with the contents of NumPy, SciLab, and SciPy. They all have seemed part of one another, but I think I see how they've divided up the game.
For the record: I know this is a bit confusing, particularly for someone used to an integrated package like Matlab, etc, but there is a lot of power an flexibility gained by the divisions: Python: is a general-purpose, extensible programming language Numpy: is a set of package of classes, functions, etc that provide facilities for numeric computation -- primarily a n-d array class and the utilities to use it. Matplotlib (MPL): is a plotting package, built on top of numpy -- it was originally designed to somewhat mimic the plotting interface of Matlab. MPL is the most commonly used plotting package for numpy, but by no means the only one. Pylab: Is a package that integrates matplotlib and numpy and an assortment of other utilities into one namespace, making it more like Matlab -- personally, I think you should avoid using it, it makes it a bit easier to type code, but harder to know where the heck what you are doing is coming from. SciPy: Is a broad collection of assorted utilities that facilitate scientific computing, built on Numpy -- it is also sometimes used as an umbrella term for anything connected to scientific computing with Python (i.e. the SciPy conferences) These distinctions are a bit confusing (particularly MPL-numpy), because MPL includes a number of utility functions that combine computation and plotting: like "hist", which both computes a histogram, and plots it as bar chart in one call -- it's a convenient way to perform a common operation, but it does blur the lines a bit! By the way -- there is also potentially a bit of confusion as to how MPL uses/interacts with the command line and GUI toolkits. This is because MPL can be used with a number of different GUI front-ends (or none), and they tend to take over control from the command line. Which brings up to: iPython: an enhanced python interactive interpreter command line system. It adds many nice features that make using python in interactive mode nicer. IN particularly, it adds a "--pylab" mode that helps it play well with MPL. You won't regret using it!
I thought I'd look through Amazon for books on Python and scientific uses. I found almost all were written by authors outside the US, and none seemed to talk about items like matplotlib.
FWIW, a book about MPL has just been published -- I don't know any more about it, but I'm sure google will tell you.
Is there a matplotlib or Pylab mailing list?
There certainly is: https://lists.sourceforge.net/lists/listinfo/matplotlib-users And yes, that is the place for such questions. HTH, -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov
On Fri, Nov 27, 2009 at 12:41 PM, Christopher Barker <Chris.Barker@noaa.gov> wrote:
Wayne Watson wrote:
Yes, I'm just beginning to deal with the contents of NumPy, SciLab, and SciPy. They all have seemed part of one another, but I think I see how they've divided up the game.
For the record:
I know this is a bit confusing, particularly for someone used to an integrated package like Matlab, etc, but there is a lot of power an flexibility gained by the divisions:
Python: is a general-purpose, extensible programming language
Numpy: is a set of package of classes, functions, etc that provide facilities for numeric computation -- primarily a n-d array class and the utilities to use it.
Matplotlib (MPL): is a plotting package, built on top of numpy -- it was originally designed to somewhat mimic the plotting interface of Matlab. MPL is the most commonly used plotting package for numpy, but by no means the only one.
Pylab: Is a package that integrates matplotlib and numpy and an assortment of other utilities into one namespace, making it more like Matlab -- personally, I think you should avoid using it, it makes it a bit easier to type code, but harder to know where the heck what you are doing is coming from.
SciPy: Is a broad collection of assorted utilities that facilitate scientific computing, built on Numpy -- it is also sometimes used as an umbrella term for anything connected to scientific computing with Python (i.e. the SciPy conferences)
These distinctions are a bit confusing (particularly MPL-numpy), because MPL includes a number of utility functions that combine computation and plotting: like "hist", which both computes a histogram, and plots it as bar chart in one call -- it's a convenient way to perform a common operation, but it does blur the lines a bit!
By the way -- there is also potentially a bit of confusion as to how MPL uses/interacts with the command line and GUI toolkits. This is because MPL can be used with a number of different GUI front-ends (or none), and they tend to take over control from the command line. Which brings up to:
iPython: an enhanced python interactive interpreter command line system. It adds many nice features that make using python in interactive mode nicer. IN particularly, it adds a "--pylab" mode that helps it play well with MPL. You won't regret using it!
I thought I'd look through Amazon for books on Python and scientific uses. I found almost all were written by authors outside the US, and none seemed to talk about items like matplotlib.
FWIW, a book about MPL has just been published -- I don't know any more about it, but I'm sure google will tell you.
Is there a matplotlib or Pylab mailing list?
There certainly is:
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
And yes, that is the place for such questions.
HTH,
-Chris
Well put, Chris. It took me a long time get my head around these distinctions, and then only when others pointed out my errors in understanding. This kind of info might be useful to other newcomers somewhere... <http://www.scipy.org/History_of_SciPy>? Thoughts on posting this on the wiki here? Skipper
On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold <jsseabold@gmail.com> wrote:
On Fri, Nov 27, 2009 at 12:41 PM, Christopher Barker <Chris.Barker@noaa.gov> wrote:
Wayne Watson wrote:
Yes, I'm just beginning to deal with the contents of NumPy, SciLab, and SciPy. They all have seemed part of one another, but I think I see how they've divided up the game.
For the record:
I know this is a bit confusing, particularly for someone used to an integrated package like Matlab, etc, but there is a lot of power an flexibility gained by the divisions:
Python: is a general-purpose, extensible programming language
Numpy: is a set of package of classes, functions, etc that provide facilities for numeric computation -- primarily a n-d array class and the utilities to use it.
Matplotlib (MPL): is a plotting package, built on top of numpy -- it was originally designed to somewhat mimic the plotting interface of Matlab. MPL is the most commonly used plotting package for numpy, but by no means the only one.
Pylab: Is a package that integrates matplotlib and numpy and an assortment of other utilities into one namespace, making it more like Matlab -- personally, I think you should avoid using it, it makes it a bit easier to type code, but harder to know where the heck what you are doing is coming from.
SciPy: Is a broad collection of assorted utilities that facilitate scientific computing, built on Numpy -- it is also sometimes used as an umbrella term for anything connected to scientific computing with Python (i.e. the SciPy conferences)
These distinctions are a bit confusing (particularly MPL-numpy), because MPL includes a number of utility functions that combine computation and plotting: like "hist", which both computes a histogram, and plots it as bar chart in one call -- it's a convenient way to perform a common operation, but it does blur the lines a bit!
By the way -- there is also potentially a bit of confusion as to how MPL uses/interacts with the command line and GUI toolkits. This is because MPL can be used with a number of different GUI front-ends (or none), and they tend to take over control from the command line. Which brings up to:
iPython: an enhanced python interactive interpreter command line system. It adds many nice features that make using python in interactive mode nicer. IN particularly, it adds a "--pylab" mode that helps it play well with MPL. You won't regret using it!
I thought I'd look through Amazon for books on Python and scientific uses. I found almost all were written by authors outside the US, and none seemed to talk about items like matplotlib.
FWIW, a book about MPL has just been published -- I don't know any more about it, but I'm sure google will tell you.
Is there a matplotlib or Pylab mailing list?
There certainly is:
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
And yes, that is the place for such questions.
HTH,
-Chris
Well put, Chris. It took me a long time get my head around these distinctions, and then only when others pointed out my errors in understanding. This kind of info might be useful to other newcomers somewhere... <http://www.scipy.org/History_of_SciPy>? Thoughts on posting this on the wiki here?
I also agree. It will improve with the newly redesigned website for scipy.org However, I cannot find the link right now for the development version of the new website. Josef
Skipper _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Fri, Nov 27, 2009 at 7:15 PM, <josef.pktd@gmail.com> wrote:
Well put, Chris. It took me a long time get my head around these distinctions, and then only when others pointed out my errors in understanding. This kind of info might be useful to other newcomers somewhere... <http://www.scipy.org/History_of_SciPy>? Thoughts on posting this on the wiki here?
+1
I also agree. It will improve with the newly redesigned website for scipy.org However, I cannot find the link right now for the development version of the new website.
josef.pktd@gmail.com wrote:
On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold <jsseabold@gmail.com> wrote:
This kind of info might be useful to other newcomers somewhere... <http://www.scipy.org/History_of_SciPy>? Thoughts on posting this on the wiki here?
I also agree. It will improve with the newly redesigned website for scipy.org However, I cannot find the link right now for the development version of the new website.
Feel free to crib whatever you want from my post for that -- or suggest a place for me to put it, and I'll do it. I'm just not sure where it should go at this point. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov
Lots of good suggestions. I'll pull them into a document for further reference. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet 350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive. Web Page: <www.speckledwithstars.net/>
Did you try using the parameter range? I do something like this. regards ax = fig.add_subplot(1,1,1)
pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)), range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
On Fri, Nov 27, 2009 at 4:38 PM, Christopher Barker <Chris.Barker@noaa.gov>wrote:
josef.pktd@gmail.com wrote:
On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold <jsseabold@gmail.com> wrote:
This kind of info might be useful to other newcomers somewhere... <http://www.scipy.org/History_of_SciPy>? Thoughts on posting this on the wiki here?
I also agree. It will improve with the newly redesigned website for scipy.org However, I cannot find the link right now for the development version of the new website.
Feel free to crib whatever you want from my post for that -- or suggest a place for me to put it, and I'll do it. I'm just not sure where it should go at this point.
-Chris
-- Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
I tried this and it put ranges on y from 0 to 0.45 and x from 5 to 50. import numpy as np import pylab v = np.array([20, 15,10,30, 50, 30, 20, 25, 10]) #Plot a normalized histogram print np.linspace(0,50,10) pylab.hist(v, normed=1, bins=np.linspace(0,9,10), range=(0,100)) pylab.show() I added the two imports. I got a fig error on the first line. import pylab import numpy Shouldn't there by a pylab.Show in there? ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)), range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value') gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1) gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True) Sebastian wrote:
Did you try using the parameter range? I do something like this. regards
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)), range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1) gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
On Fri, Nov 27, 2009 at 4:38 PM, Christopher Barker <Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov>> wrote:
josef.pktd@gmail.com <mailto:josef.pktd@gmail.com> wrote: > On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold <jsseabold@gmail.com <mailto:jsseabold@gmail.com>> wrote:
>> This kind of info might be useful to other newcomers >> somewhere... <http://www.scipy.org/History_of_SciPy>? Thoughts on >> posting this on the wiki here? > > I also agree. It will improve with the newly redesigned website for scipy.org <http://scipy.org> > However, I cannot find the link right now for the development version of > the new website.
Feel free to crib whatever you want from my post for that -- or suggest a place for me to put it, and I'll do it. I'm just not sure where it should go at this point.
-Chris
-- Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov> _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org <mailto:NumPy-Discussion@scipy.org> http://mail.scipy.org/mailman/listinfo/numpy-discussion
------------------------------------------------------------------------
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet 350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive. Web Page: <www.speckledwithstars.net/>
Hi Chris, yeah there should, try the following: import numpy import matplotlib.pyplot as pylab regards On Fri, Nov 27, 2009 at 8:47 PM, Wayne Watson <sierra_mtnview@sbcglobal.net>wrote:
I tried this and it put ranges on y from 0 to 0.45 and x from 5 to 50.
import numpy as np import pylab
v = np.array([20, 15,10,30, 50, 30, 20, 25, 10]) #Plot a normalized histogram print np.linspace(0,50,10) pylab.hist(v, normed=1, bins=np.linspace(0,9,10), range=(0,100)) pylab.show()
I added the two imports. I got a fig error on the first line. import pylab import numpy
Shouldn't there by a pylab.Show in there?
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
Sebastian wrote:
Did you try using the parameter range? I do something like this. regards
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)),
normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value))
pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
On Fri, Nov 27, 2009 at 4:38 PM, Christopher Barker <Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov>> wrote:
josef.pktd@gmail.com <mailto:josef.pktd@gmail.com> wrote: > On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold <jsseabold@gmail.com <mailto:jsseabold@gmail.com>> wrote:
>> This kind of info might be useful to other newcomers >> somewhere... <http://www.scipy.org/History_of_SciPy>? Thoughts
on
>> posting this on the wiki here? > > I also agree. It will improve with the newly redesigned website for scipy.org <http://scipy.org> > However, I cannot find the link right now for the development version of > the new website.
Feel free to crib whatever you want from my post for that -- or suggest a place for me to put it, and I'll do it. I'm just not sure where it should go at this point.
-Chris
-- Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov> _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org <mailto:NumPy-Discussion@scipy.org> http://mail.scipy.org/mailman/listinfo/numpy-discussion
------------------------------------------------------------------------
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Fri, Nov 27, 2009 at 9:05 PM, Sebastian <sebas0@gmail.com> wrote:
Hi Chris, yeah there should, try the following: import numpy import matplotlib.pyplot as pylab regards
On Fri, Nov 27, 2009 at 8:47 PM, Wayne Watson <sierra_mtnview@sbcglobal.net> wrote:
I tried this and it put ranges on y from 0 to 0.45 and x from 5 to 50.
import numpy as np import pylab
v = np.array([20, 15,10,30, 50, 30, 20, 25, 10]) #Plot a normalized histogram print np.linspace(0,50,10) pylab.hist(v, normed=1, bins=np.linspace(0,9,10), range=(0,100)) pylab.show()
I added the two imports. I got a fig error on the first line. import pylab import numpy
Shouldn't there by a pylab.Show in there?
you need to create a figure, before you can use it fig = pylab.figure() Josef
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
Sebastian wrote:
Did you try using the parameter range? I do something like this. regards
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
On Fri, Nov 27, 2009 at 4:38 PM, Christopher Barker <Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov>> wrote:
josef.pktd@gmail.com <mailto:josef.pktd@gmail.com> wrote: > On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold <jsseabold@gmail.com <mailto:jsseabold@gmail.com>> wrote:
>> This kind of info might be useful to other newcomers >> somewhere... <http://www.scipy.org/History_of_SciPy>? Thoughts on >> posting this on the wiki here? > > I also agree. It will improve with the newly redesigned website for scipy.org <http://scipy.org> > However, I cannot find the link right now for the development version of > the new website.
Feel free to crib whatever you want from my post for that -- or suggest a place for me to put it, and I'll do it. I'm just not sure where it should go at this point.
-Chris
-- Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov> _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org <mailto:NumPy-Discussion@scipy.org> http://mail.scipy.org/mailman/listinfo/numpy-discussion
------------------------------------------------------------------------
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Joseph, That got it by the fig problem but there is yet another one. value is not defined on the very long line: range = ... Wayne josef.pktd@gmail.com wrote:
On Fri, Nov 27, 2009 at 9:05 PM, Sebastian <sebas0@gmail.com> wrote:
... you need to create a figure, before you can use it
fig = pylab.figure()
Josef
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
Sebastian wrote:
Did you try using the parameter range? I do something like this. regards
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
On Fri, Nov 27, 2009 at 4:38 PM, Christopher Barker <Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov>> wrote:
josef.pktd@gmail.com <mailto:josef.pktd@gmail.com> wrote: > On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold <jsseabold@gmail.com <mailto:jsseabold@gmail.com>> wrote:
>> This kind of info might be useful to other newcomers >> somewhere... <http://www.scipy.org/History_of_SciPy>? Thoughts on >> posting this on the wiki here? > > I also agree. It will improve with the newly redesigned website for scipy.org <http://scipy.org> > However, I cannot find the link right now for the development version of > the new website.
Feel free to crib whatever you want from my post for that -- or suggest a place for me to put it, and I'll do it. I'm just not sure where it should go at this point.
-Chris
-- Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov> _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org <mailto:NumPy-Discussion@scipy.org> http://mail.scipy.org/mailman/listinfo/numpy-discussion
------------------------------------------------------------------------
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet 350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive. Web Page: <www.speckledwithstars.net/>
On Fri, Nov 27, 2009 at 9:44 PM, Wayne Watson <sierra_mtnview@sbcglobal.net> wrote:
Joseph, That got it by the fig problem but there is yet another one. value is not defined on the very long line: range = ... Wayne
(values is the data array, ... no idea about scientificstat.standardDeviation) Sebastian's example is only part of a larger script that defines many of the variables and functions that are used. If you are not yet familiar with these examples, maybe you look at the self contained examples in the matplotlib docs. At least that's what I do when I only have a rough idea about what graph I want to do but don't know how to do it with matplotlib. I usually just copy a likely looking candidate and change it until it (almost) produces what I want. For example look at histogram examples in http://matplotlib.sourceforge.net/examples/index.html Josef
josef.pktd@gmail.com wrote:
On Fri, Nov 27, 2009 at 9:05 PM, Sebastian <sebas0@gmail.com> wrote:
... you need to create a figure, before you can use it
fig = pylab.figure()
Josef
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
Sebastian wrote:
Did you try using the parameter range? I do something like this. regards
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
On Fri, Nov 27, 2009 at 4:38 PM, Christopher Barker <Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov>> wrote:
josef.pktd@gmail.com <mailto:josef.pktd@gmail.com> wrote: > On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold <jsseabold@gmail.com <mailto:jsseabold@gmail.com>> wrote:
>> This kind of info might be useful to other newcomers >> somewhere... <http://www.scipy.org/History_of_SciPy>? Thoughts on >> posting this on the wiki here? > > I also agree. It will improve with the newly redesigned website for scipy.org <http://scipy.org> > However, I cannot find the link right now for the development version of > the new website.
Feel free to crib whatever you want from my post for that -- or suggest a place for me to put it, and I'll do it. I'm just not sure where it should go at this point.
-Chris
-- Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov> _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org <mailto:NumPy-Discussion@scipy.org> http://mail.scipy.org/mailman/listinfo/numpy-discussion
------------------------------------------------------------------------
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Sat, Nov 28, 2009 at 1:01 AM, <josef.pktd@gmail.com> wrote:
On Fri, Nov 27, 2009 at 9:44 PM, Wayne Watson <sierra_mtnview@sbcglobal.net> wrote:
Joseph, That got it by the fig problem but there is yet another one. value is not defined on the very long line: range = ... Wayne
(values is the data array, ... no idea about scientificstat.standardDeviation)
Sebastian's example is only part of a larger script that defines many of the variables and functions that are used.
If you are not yet familiar with these examples, maybe you look at the self contained examples in the matplotlib docs. At least that's what I do when I only have a rough idea about what graph I want to do but don't know how to do it with matplotlib. I usually just copy a likely looking candidate and change it until it (almost) produces what I want. For example look at histogram examples in
http://matplotlib.sourceforge.net/examples/index.html
Josef
josef.pktd@gmail.com wrote:
On Fri, Nov 27, 2009 at 9:05 PM, Sebastian <sebas0@gmail.com> wrote:
... you need to create a figure, before you can use it
fig = pylab.figure()
Josef
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)),
normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value))
pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
Sebastian wrote:
Did you try using the parameter range? I do something like this. regards
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)),
normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value))
pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
On Fri, Nov 27, 2009 at 4:38 PM, Christopher Barker <Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov>> wrote:
josef.pktd@gmail.com <mailto:josef.pktd@gmail.com> wrote: > On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold <jsseabold@gmail.com <mailto:jsseabold@gmail.com>> wrote:
>> This kind of info might be useful to other newcomers >> somewhere... <http://www.scipy.org/History_of_SciPy>?
Thoughts
on >> posting this on the wiki here? > > I also agree. It will improve with the newly redesigned website for scipy.org <http://scipy.org> > However, I cannot find the link right now for the development version of > the new website.
Feel free to crib whatever you want from my post for that -- or suggest a place for me to put it, and I'll do it. I'm just not sure where it should go at this point.
-Chris
-- Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov> _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org <mailto:NumPy-Discussion@scipy.org> http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Chris I',m using the package Scientific.Stats to calculate the standard deviation. I believe it is from here: http://dirac.cnrs-orleans.fr/plone/software/scientificpython/ I use the Scientific.Stats package for the standard deviation calculation because back when I wrote the code I realized that numpy's standard deviation seems to assume that you have all the distribution (the parent population),while I think the Scientific.Stats is more accurate for smaller samples. But maybe there is an equivalent numpy standard deviation. If I recall OK the difference is an (n-1) instead of an (n) in the formula. For larger samples both the numpy and the Scientific.Stats standard deviation shouldn't be too different . So I use the range to specify the values to bin over. It seems you might want your range parameter to be different. I'm choosing the range to be +/- 3-sigma, and that way ignore values that are too extreme so my bins a more concentrated about the distribution. OK so I also have to add the following import line in the code, too: import Scientific.Statistics as scientificstat Sebas
On Sat, Nov 28, 2009 at 6:18 AM, Sebastian <sebas0@gmail.com> wrote:
On Sat, Nov 28, 2009 at 1:01 AM, <josef.pktd@gmail.com> wrote:
On Fri, Nov 27, 2009 at 9:44 PM, Wayne Watson <sierra_mtnview@sbcglobal.net> wrote:
Joseph, That got it by the fig problem but there is yet another one. value is not defined on the very long line: range = ... Wayne
(values is the data array, ... no idea about scientificstat.standardDeviation)
Sebastian's example is only part of a larger script that defines many of the variables and functions that are used.
If you are not yet familiar with these examples, maybe you look at the self contained examples in the matplotlib docs. At least that's what I do when I only have a rough idea about what graph I want to do but don't know how to do it with matplotlib. I usually just copy a likely looking candidate and change it until it (almost) produces what I want. For example look at histogram examples in
http://matplotlib.sourceforge.net/examples/index.html
Josef
josef.pktd@gmail.com wrote:
On Fri, Nov 27, 2009 at 9:05 PM, Sebastian <sebas0@gmail.com> wrote:
... you need to create a figure, before you can use it
fig = pylab.figure()
Josef
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
Sebastian wrote:
> Did you try using the parameter range? > I do something like this. > regards > > ax = fig.add_subplot(1,1,1) > pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') > n, bins, patches = pylab.hist(values, > bins=math.sqrt(len(values)), > > > range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), > normed=1, facecolor='y', alpha=0.5) > ax.set_xlabel(r'\Large$ \rm{values}$') > ax.set_ylabel(r'\Large Delatavalue/Value') > > > > gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1) > > > gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) > pylab.plot(gausx,gaus, color='red', lw=2) > ax.set_xlim(-1.5, 1.5) > ax.grid(True) > > > On Fri, Nov 27, 2009 at 4:38 PM, Christopher Barker > <Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov>> wrote: > > josef.pktd@gmail.com <mailto:josef.pktd@gmail.com> wrote: > > On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold > <jsseabold@gmail.com <mailto:jsseabold@gmail.com>> wrote: > > >> This kind of info might be useful to other newcomers > >> somewhere... <http://www.scipy.org/History_of_SciPy>? > Thoughts > on > >> posting this on the wiki here? > > > > I also agree. It will improve with the newly redesigned > website > for scipy.org <http://scipy.org> > > However, I cannot find the link right now for the development > version of > > the new website. > > Feel free to crib whatever you want from my post for that -- or > suggest > a place for me to put it, and I'll do it. I'm just not sure > where it > should go at this point. > > -Chris > > > -- > Christopher Barker, Ph.D. > Oceanographer > > Emergency Response Division > NOAA/NOS/OR&R (206) 526-6959 voice > 7600 Sand Point Way NE (206) 526-6329 fax > Seattle, WA 98115 (206) 526-6317 main reception > > Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov> > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org <mailto:NumPy-Discussion@scipy.org> > http://mail.scipy.org/mailman/listinfo/numpy-discussion > > > > ------------------------------------------------------------------------ > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Chris I',m using the package Scientific.Stats to calculate the standard deviation. I believe it is from here: http://dirac.cnrs-orleans.fr/plone/software/scientificpython/ I use the Scientific.Stats package for the standard deviation calculation because back when I wrote the code I realized that numpy's standard deviation seems to assume that you have all the distribution (the parent population),while I think the Scientific.Stats is more accurate for smaller samples. But maybe there is an equivalent numpy standard deviation. If I recall OK the difference is an (n-1) instead of an (n) in the formula. For larger samples both the numpy and the Scientific.Stats standard deviation shouldn't be too different
numpy std and var have a ddof option to adjust the degrees of freedom. ddof=0 by default, but you can set ddof=1 to get denominator (n-1) there was a long discussion on bias and bias correction on the mailing list a few months ago. Josef
. So I use the range to specify the values to bin over. It seems you might want your range parameter to be different. I'm choosing the range to be +/- 3-sigma, and that way ignore values that are too extreme so my bins a more concentrated about the distribution. OK so I also have to add the following import line in the code, too:
import Scientific.Statistics as scientificstat
Sebas
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Fri, Nov 27, 2009 at 8:05 PM, Sebastian <sebas0@gmail.com> wrote:
Hi Chris, yeah there should, try the following: import numpy import matplotlib.pyplot as pylab regards
Shouldn't the 2nd import be: import matplotlib.pyplot as plt ?
On Fri, Nov 27, 2009 at 8:47 PM, Wayne Watson < sierra_mtnview@sbcglobal.net> wrote:
I tried this and it put ranges on y from 0 to 0.45 and x from 5 to 50.
import numpy as np import pylab
v = np.array([20, 15,10,30, 50, 30, 20, 25, 10]) #Plot a normalized histogram print np.linspace(0,50,10) pylab.hist(v, normed=1, bins=np.linspace(0,9,10), range=(0,100)) pylab.show()
I added the two imports. I got a fig error on the first line. import pylab import numpy
Shouldn't there by a pylab.Show in there?
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)), normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value)) pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
Sebastian wrote:
Did you try using the parameter range? I do something like this. regards
ax = fig.add_subplot(1,1,1) pylab.title(r'\Large BCG NO radio distribution $ \rm{TITLE}$') n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)),
normed=1, facecolor='y', alpha=0.5) ax.set_xlabel(r'\Large$ \rm{values}$') ax.set_ylabel(r'\Large Delatavalue/Value')
gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value))
pylab.plot(gausx,gaus, color='red', lw=2) ax.set_xlim(-1.5, 1.5) ax.grid(True)
On Fri, Nov 27, 2009 at 4:38 PM, Christopher Barker <Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov>> wrote:
josef.pktd@gmail.com <mailto:josef.pktd@gmail.com> wrote: > On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold <jsseabold@gmail.com <mailto:jsseabold@gmail.com>> wrote:
>> This kind of info might be useful to other newcomers >> somewhere... <http://www.scipy.org/History_of_SciPy>? Thoughts
on
>> posting this on the wiki here? > > I also agree. It will improve with the newly redesigned website for scipy.org <http://scipy.org> > However, I cannot find the link right now for the development version of > the new website.
Feel free to crib whatever you want from my post for that -- or suggest a place for me to put it, and I'll do it. I'm just not sure where it should go at this point.
-Chris
-- Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov <mailto:Chris.Barker@noaa.gov> _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org <mailto:NumPy-Discussion@scipy.org> http://mail.scipy.org/mailman/listinfo/numpy-discussion
------------------------------------------------------------------------
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive.
Web Page: <www.speckledwithstars.net/>
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Gökhan
Yes, the book description is here <http://www.amazon.com/gp/search/ref=sr_adv_b/?search-alias=stripbooks&unfiltered=1&field-keywords=&field-author=&field-title=matplotlib+python&field-isbn=&field-publisher=&node=&url=&field-feature_browse-bin=&field-binding_browse-bin=&field-subject=&field-language=&field-dateop=&field-datemod=&field-dateyear=&sort=relevancerank&Adv-Srch-Books-Submit.x=0&Adv-Srch-Books-Submit.y=0> Christopher Barker wrote:
... FWIW, a book about MPL has just been published -- I don't know any more about it, but I'm sure google will tell you.
Is there a matplotlib or Pylab mailing list?
There certainly is:
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
And yes, that is the place for such questions.
HTH,
-Chris
-- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet 350 350 350 350 350 350 350 350 350 350 Make the number famous. See 350.org The major event has passed, but keep the number alive. Web Page: <www.speckledwithstars.net/>
participants (8)
-
Christopher Barker
-
Gökhan Sever
-
josef.pktd@gmail.com
-
Ralf Gommers
-
Sebastian
-
Skipper Seabold
-
Vincent Schut
-
Wayne Watson