Ask Your Question

deebs67's profile - activity

2016-04-17 13:31:11 +0200 received badge  Famous Question (source)
2015-09-23 20:49:15 +0200 received badge  Taxonomist
2014-01-29 22:43:21 +0200 received badge  Notable Question (source)
2013-05-15 08:52:27 +0200 received badge  Popular Question (source)
2012-09-18 12:52:48 +0200 received badge  Famous Question (source)
2011-12-04 16:37:14 +0200 received badge  Notable Question (source)
2011-08-29 06:25:48 +0200 received badge  Popular Question (source)
2011-06-09 16:23:06 +0200 commented answer How to control layouts of individual plots within a graphics_array?

Actually, now I've done more experiments I realise that .show() wasn't actually helping me to control the aspect_ratio of myPlot2 within the graphics_array. I thought it did, but it was just that by default it gave me an aspect ratio close to 1.0, which by eye I assumed was exactly 1.0, but it wasn't. So I will get the aspect_ratio I ask for in the .show() operation, but it doesn't seem to influence what I get in the graphics_array.show(). As for .save(), in terms of what I see on the screen, I seem to get the same as .show(). The set_axes_range was the top tip which means that things work well enough for my purposes now without needing any myPlotx.show() statements. So thanks for that.

2011-06-09 13:36:41 +0200 commented answer How to control layouts of individual plots within a graphics_array?

Thanks for that. The tip about set_axes_range allowed me to remove one of the 'myPlotx.show()' operations. Unfortunately, since I want a different aspect_ratio between the two plots, I couldn't eliminate the other.

2011-06-09 11:33:20 +0200 received badge  Editor (source)
2011-06-09 10:42:41 +0200 asked a question How to control layouts of individual plots within a graphics_array?

I am trying to plot two graphics side-by side from with an '@interact' function within the Sage notebook.

I define my graphics array and render it with the appropriate size as follows:

myGraphicsArray = graphics_array([myPlot1, myPlot2])

myGraphicsArray.show(figsize=[14,5])

This is fine, but how can I control features of the individual plots separately? (e.g. axis range, aspect ratio, maybe even relative sizes of the two plots etc.)

For now I have found a kludge workaround, which is to .show() the individual plots first of all (making them very small) within which I set the relevant layout parameters as follows:

myPlot1.show(ymin=-40,ymax=10,figsize=0.1) # note small figsize

myPlot2.show(xmin=-axisMax, xmax=axisMax, ymin=-axisMax, ymax=axisMax, aspect_ratio=1, figsize=0.1) # note small figsize

This is not ideal, as it plots them (albeit small) when I didn't really want to. But at least it allows me to control their respective layouts when they later appear within the graphics_array.

But is there a better way to do this?

2011-05-18 08:01:46 +0200 commented answer 3d plots without Java

It seems to need a var('x,y') before the plot3d() example in the answer above (it did for me anyhow)

2011-05-03 12:54:33 +0200 marked best answer Plotting in 3D in spherical coordinates

Can you use the plot_points option in spherical_plot3d to get a finer u,v grid?

2011-05-03 12:54:33 +0200 received badge  Scholar (source)
2011-05-03 12:54:29 +0200 commented answer Plotting in 3D in spherical coordinates

Another great answer! Yes, this worked a treat, and avoids the residual 'shaded plane' problem I found with the 'list_plot3d()' approach described above. So this solves my problem entirely. Thanks.

2011-04-20 18:48:23 +0200 received badge  Student (source)
2011-04-19 10:34:04 +0200 commented answer Plotting in 3D in spherical coordinates

Great answer! The only slight issue is that using parametric_plot3d() as you did above works fine for the sphere, but I still get the 'blocky/smoothed' problems as per a) when I try to plot my full (complicated) antenna radiation pattern in this way. This is presumably because Sage takes care of controlling the resolution, without giving me the option (??). But I can still use your 'North'+'South' trick with list_plot3d(). However, this does have the drawback that the plots also shade the x,y plane. So when I plot my full antenna radiation pattern in this way (or the sphere described above) it is bisected by a coloured plane at z=0. But other than that the problem is solved. Thanks.

2011-04-19 10:09:56 +0200 received badge  Supporter (source)
2011-04-19 08:28:25 +0200 asked a question Plotting in 3D in spherical coordinates

My problem is that I am trying to plot (in full 3D spherical coordinates) a set of values stored in a 2D lookup table or LUT. The LUT is actually stored as a numpy 1801*3601 2D array indexed by theta and phi respectively in 0.1 degree steps. The LUT in fact represents an antenna radiation pattern (i.e. antenna gain/ radiation intensity as a function of theta and phi). However, my problem generalises to any one of plotting a function in spherical coordinates.

My first attempt at plotting this in Sage was to use the 'spherical_plot3d()' function. First I defined a function called:

getGain(phiInRadians, thetaInRadians)

which returned a value from the lookup table (LUT) representing antenna gain (a positive number in decibels). Then I tried plotting this as follows:

sage: spherical_plot3d(getGain,(-3.142,3.142),(0,3.142)).show(aspect_ratio=(1,1,1))

Now this almost does what I want, but not quite. My LUT has a high resolution with 0.1 degree intervals. However, the 3D plot which the above command delivers (via Jmol) seems to smooth the pattern where I don't want it to be smoothed (because it has abrupt edges), and is too 'blocky' where I would like the pattern to be smooth. Is there any way I can have fine control of the step-size in phi and theta (u and v in Sage-speak), or must I leave it to Sage to control these?

I also tried a different approach, which is to use list_plot3d, but to transform the coordinates from spherical to rectangular when building up my list to plot. To discuss this case we can simplify the problem to say that we wish to plot the radiation pattern of an isotropic antenna, i.e. one which has equal gain in all directions. Thus what we are simply trying to do is to plot a sphere in 3 dimensions from a list of 3-tuples, where each tuple represents an (x,y,z) coordinate in Cartesian space. However, when generating the points to plot I transform from spherical to cartesian coordinates when setting up the list of points to plot, thus:

sage: import numpy as np

sage: r=1 # Representing the gain of an isotropic antenna

sage: listOfPointsOnSurfaceOfSphere = [ (r* sin(theta) * cos(phi), r* sin(theta)* sin(phi), r* getGain(phi,theta)* cos(theta)) for theta in np.arange(0.1,pi,0.1) for phi in np.arange(-pi,pi,0.1) ]

sage: myPlot1 = list_plot3d(listOfPointsOnSurfaceOfSphere).show()

Now what I find is that my plot is all 'spiky', whereas I was hoping to see a smooth sphere. Of course, what is happening is that I have multiple points with the same (or similar) (x,y) coordinates, but very different z coordinates, since every point on the sphere 'above the equator' (i.e. above the x,y plane) has effective neighbours as mirror images below. This seems to be screwing up the interpolation routine, which isn't able to identify that it ... (more)