1 Jun 11:26 2009

### Re: How to use pcolor and scatter plot in one image?

Hi,

thanks for your help. Unfortunately, your example does not work for me. The line
histo = np.histogram(z.ravel(), bins=r_[Z.ravel(),2*n**2]) produeces the following error message:
Traceback (most recent call last): File "/mnt/VBoxShare/eg.py", line 15, in <module> histo = np.histogram(z.ravel(), bins=r_[Z.ravel(),2*n**2]) NameError: name 'r_' is not defined I'm very new to Scipy and have no idea what your intended to do there.

What I'm trying to do is the following:
from scipy import polyval, zeros import pylab a, b = fetch_data(...) pylab.plot(a, b, "g.") # scatter plot # regression line regression = regression_analysis(...) xr = polyval([regression[0], regression[1]], b) pylab.plot(b, xr, "r-") pylab.gca().set_xlim([0,max(b)]) pylab.gca().set_ylim([0,max(a)]) # calculate grid (10x10) xlim = pylab.gca().get_xlim()[1] ylim = pylab.gca().get_ylim()[1] block_x = int(xlim / 10.0 + 1) block_y = int(ylim / 10.0 + 1) grid_x = [ block_x * i for i in range(11) ] grid_y = [ block_y * i for i in range(11) ] density_map = zeros((10, 10)) # matrix for points per cell inc = 1.0 / number_of_data_points for i in range(10): for j in range(10): cell = [ grid_x[i], grid_x[i+1], grid_y[j], grid_y[j+1] ] density_map[j][i] += points_in(cell) * inc # plot the 'density map' pylab.pcolor(density_map, cmap=pylab.get_cmap("hot")) pylab.show()
This only creates the scatter plot and the regression line.

kind regards
robert
```_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
```
1 Jun 11:36 2009

### Re: How to use pcolor and scatter plot in one image?

```On Mon, Jun 01, 2009 at 11:26:38AM +0200, wierob wrote:
>    thanks for your help. Unfortunately, your example does not work for me.
>    The line

>  histo = np.histogram(z.ravel(), bins=r_[Z.ravel(),2*n**2])

>    produeces the following error message:

>  Traceback (most recent call last):
>    File "/mnt/VBoxShare/eg.py", line 15, in <module>
>      histo = np.histogram(z.ravel(), bins=r_[Z.ravel(),2*n**2])
>  NameError: name 'r_' is not defined

That was a typo: replace 'r_' by 'np.r_'.

Gaël

PS: IPython dev's: is there a pylab mode without the dreaded
'from pylab import *'. We need to advertise such a workflow, rather the
'ipython -pylab' which polutes the namespace with almost 900 entries.
```
1 Jun 11:51 2009

### projection of a point to a set defined by linear constraints

```hi all,
Suppose I have set of linear constraints
b1 <= Ax <= b2
and point X = [x1, ..., xn] out of the set.

A is n x m matrix, b1, b2 are vectors of length m (some of b2, b1
coords can be +/- inf or equal).

What is the best way to find projection of the point x to the
set? I.e. ||X-x||_2 -> min, s.t. b1 <= Ax <= b2.

I intended to use constrained LLSP solver,
something like ACM TOMS 587

But:
* Using f2py yields error, as I have mentioned here

* Since the problem has eye matrix (||Cx-d||^2 -> min, C = I), I
thought maybe there are more efficient ways (and/or software) to do
it?

Could you recommend me another forum/google group where I should
search, an article or mb some code (preferably Python or MATLAB)?

I was recommended to involving ODRPack and I know it is included into
scipy, can this somehow help?
BTW I intend to involve it to speedup my NLP/NSP sover ralg for problems
with lots of constraints, other than only box-bounded ones.

D.
```
1 Jun 13:20 2009

### Re: How to use pcolor and scatter plot in one image?

```	Hi Robert,

>  histo = np.histogram(z.ravel(), bins=r_[Z.ravel(),2*n**2])

>    produeces the following error message:

>  Traceback (most recent call last):
>    File "/mnt/VBoxShare/eg.py", line 15, in <module>
>      histo = np.histogram(z.ravel(), bins=r_[Z.ravel(),2*n**2])
>  NameError: name 'r_' is not defined

As Gaël said, it should be np.r_ instead of r_. It's just that I
executed my code into ipython -pylab that enables the interactive use of
matplotlib, but also loads a lot of pylab and numpy features into the
namespace. Sorry about the typo! You should try to execute the code
again. I used np.r_ to concatenate the array Z.ravel() with 2*n**2 in
order to add the upper_edge of the last bin for the histogram (note: if
you don't use a recent version of numpy, histogram may return an error).

* I guess one of the problems might be that you're using two different
scales for the data and for your grid. pcolor(density_map) plots the
color levels corresponding to density_map on a y-scale (x-scale) between
0 and max_index_along_first_direction - 1 (that does not correspond to
the values of the data). That may explain why your data and your
density_map do not superpose. You should define X and Y coordinates of
the grid (e.g. using np.mgrid as in my example) and plot pcolor(X, Y,
density_map).
* Rather than grid_x = [ block_x * i for i in range(11) ], use
np.linspace(0, block_x*11, 11, endpoint=False) or np.arange(0, block_x*11, block_x)
* You can avoid easily your for loop using numpy.histogram2d that does
just what you want for putting your points inside the bins of the grid.
Try np.histogram2d(a, b, bins=11, range=[[0, xlim], [0, ylim]]) (check
the documentation first).

Hope this helps,
Emmanuelle

PS: actually this discussion should rather be on the numpy-discussion
list. I would advise you to suscribe to this list and -- if you have

>    I'm very new to Scipy and have no idea what your intended to do there.

>    What I'm trying to do is the following:

>  from scipy import polyval, zeros
>  import pylab

>  a, b = fetch_data(...)

>  pylab.plot(a, b, "g.")  # scatter plot

>  # regression line
>  regression = regression_analysis(...)
>  xr = polyval([regression[0], regression[1]], b)
>  pylab.plot(b, xr, "r-")

>  pylab.gca().set_xlim([0,max(b)])
>  pylab.gca().set_ylim([0,max(a)])

>  # calculate grid (10x10)

>  xlim = pylab.gca().get_xlim()[1]
>  ylim = pylab.gca().get_ylim()[1]
>  block_x = int(xlim / 10.0 + 1)
>  block_y = int(ylim / 10.0 + 1)
>  grid_x = [ block_x * i for i in range(11) ]
>  grid_y = [ block_y * i for i in range(11) ]

>  density_map = zeros((10, 10))   # matrix for points per cell

>  inc = 1.0 / number_of_data_points

>  for i in range(10):
>      for j in range(10):
>          cell = [ grid_x[i], grid_x[i+1], grid_y[j], grid_y[j+1] ]
>          density_map[j][i] += points_in(cell) * inc

>  # plot the 'density map'
>  pylab.pcolor(density_map, cmap=pylab.get_cmap("hot"))

>  pylab.show()

>    This only creates the scatter plot and the regression line.

>    kind regards
>    robert

> _______________________________________________
> SciPy-user mailing list
> SciPy-user <at> scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
```
1 Jun 19:16 2009

### Import statements

```I recently installed the Superpack on some of the "server" (they don't
run MAC OS Server) computers in my group in order to use them to run
data analysis programs in the background overnight while they continue
to perform their normal file sharing purposes.  However, the Superpack
build of scipy seems to create issues with one of my home made packages
that is dependant on scipy.  In particular, the problem seems to be a
"import scipy.stats" statement in my home package.  Said statement also
fails in the command line interpreter with a error that reports that
scipy has no stats module (attribute), which contradicts what's in the
help statements for scipy.

Has there been a recent change in the structure of scipy that hasn't
made it into the help documentation yet?
--

--

Research Assistant
Department of Physics and Astronomy
University of Maine
Bennett 309
Office Hours: By appointment only
```
Attachment (smime.p7s): application/x-pkcs7-signature, 7616 bytes
```_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
```
1 Jun 19:24 2009

### Re: Import statements

```On Mon, Jun 1, 2009 at 12:16, R. Padraic Springuel
<R.Springuel <at> umit.maine.edu> wrote:
> I recently installed the Superpack on some of the "server" (they don't run
> MAC OS Server) computers in my group in order to use them to run data
> analysis programs in the background overnight while they continue to perform
> their normal file sharing purposes.  However, the Superpack build of scipy
> seems to create issues with one of my home made packages that is dependant
> on scipy.  In particular, the problem seems to be a "import scipy.stats"
> statement in my home package.  Said statement also fails in the command line
> interpreter with a error that reports that scipy has no stats module
> (attribute), which contradicts what's in the help statements for scipy.

"import scipy.stats" should work. "import scipy; scipy.stats" should not.

Please copy-and-paste error messages along with the code that created
them rather than trying to describe them.

--

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
```
1 Jun 22:25 2009

### software review: econometrics with python

```I just found this

http://www3.interscience.wiley.com/journal/122363228/abstract

Josef
```
1 Jun 22:23 2009

### Re: How to use pcolor and scatter plot in one image?

```Hi,
> * I guess one of the problems might be that you're using two different
> scales for the data and for your grid.
that's it.

Thanks a lot.

kind regards
robert
```
1 Jun 23:42 2009

### Re: software review: econometrics with python

```
On 1-Jun-09, at 4:25 PM, josef.pktd <at> gmail.com wrote:

> I just found this
>
> http://www3.interscience.wiley.com/journal/122363228/abstract

Vaguely relevant, also:

http://johnstachurski.net/lectures/

Tons of scipy-based computational economics example code.

David
```
2 Jun 07:35 2009

### quaternion and slerp interpolator, and all that

```
Hello,
I would be interested in quaternions, spherical rotations, and
interpolations thereof, a la slerp..... I quickly look at the online doc
of scipy/numpy, and did not find any mention of these. Can someone point
me to such functionalities in either package?

thanks,
Johann
```

Gmane