# [SciPy-user] Simple plot problem

Guilherme P. de Freitas guilherme@gpfreitas....
Tue Feb 17 04:00:06 CST 2009

```Hi Gael,

So, I tried your code, and I got the same problem: the parametric
curves are "shrinked". I don't know if it's a bug in my system, but
the parametric curves are just not right. You can see a picture here:

http://archive.gpfreitas.com/misc/snapshot.png

I had achieved this before. As I said, the problem is with the
parametric curves, not with the f function.

Thanks!

Guilherme

On Tue, Feb 17, 2009 at 1:46 AM, Gael Varoquaux
<gael.varoquaux@normalesup.org> wrote:
> On Tue, Feb 17, 2009 at 01:23:20AM -0800, Guilherme P. de Freitas wrote:
>> I need to plot three simpe things, in 3d, domain is x, y in [0,3] x
>> [0,3:
>
>> 1. the graph of the function f(x,y) = x**(0.3) * y**(0.7)
>> 2. the parametric straight line (x, 2 - 2*x, 0)  for x in [0,1]
>> 3. the parametric curve (x, 2 - 2*x, f(x, 2 - 2*x))
>
> Here is some code that probably does what you want. Use the keyword
> arguments of the plotting functions to change the different properties
> (such as linewidth) of the objects created):
>
> ################################################################################
> import numpy as np
> from enthought.mayavi import mlab
>
> x, y = np.mgrid[0:3:100j, 0:3:100j]
> def f(x, y):
>    return x**(0.3) * y**(0.7)
> mlab.surf(x, y, f)
>
> x = np.linspace(0, 1, 100)
> mlab.plot3d(x, 2-2*x, np.zeros_like(x))
> mlab.plot3d(x, 2 - 2*x, f(x, 2 - 2*x))
> mlab.show()
> ################################################################################
>
> I would interested in figuring out what posed problem in the
> documentation, and how things could be improved. The trick is to create
> arrays to evaluate the functions on: x and y. For a surface, you need to
> create a 2D array, in other words a grid of x and y varying in the 2
> directions. This is what the mgrid function does. Maybe a note about
> mgrid in the documentation relative to plotting surface could help?
>
> HTH,
>
> Gaël
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>

--
Guilherme P. de Freitas
http://www.gpfreitas.com
```