Well, the problem I have is the following one.
I have data for axis X, Y and Z, and I want to plot the surface. For that I first interpolate/extrapolate to get , more mesh points and then I plot the surface (in Python) with plot_surface() function and I get it.
Later I have to use those points that I have for the mesh (already interpolated) as input in another function. As output I want the new surface and get it. But how can I get the coordinates of every point of that surface? As if I pointed with the cursor at that point.
I have to interpolate again?
Or there is other way?
Related
My goal is to create a 3d plot of the field inside a Paul trap. I've been trying to do this 3D plot without any success. My problem is that I have a 3D matrix that represents the potential everywhere in space, but I haven't found a way to plot it as a contour or color map.
All the options I saw required me to create a meshgrid of x and y and then plot z as a function of x and y, which isn't what I need because the potential depends on all 3 coordinates. Does anyone know of a function to plot in such a way, or at least a way to trick other functions into doing what I need?
Thank you in advance!
Suppose I have a cone of evenly distributed points starting at (0,0,0) and with its main axes along (0,0,1). I need to create a python script that rotates all points, so the cone is parallel to (1,1,1). What is the easiest way to to this using spherical coordinates?
For now, I've been transforming my spherical coordinates to cartesian ones, applying Rodrigue's formula and finally transforming the coordinates back again to spherical. But there should be an easier way, right?
I am currently working on a 3D simulation data. I have a 3D surface, for simplicity, lets say, I have a hemispherical surface. So naturally, I have all the (x,y,z) coordinates that make up the surface. Now I also have a fourth array having the values of some variable (say Pressure for example) at all the (x,y,z) locations that make up the hemispherical surface. My aim is to plot the hemispherical surface and the surface should be coloured according to the fourth array (i.e according to the value of Pressure at that surface).
I have tried pyplot.scatter function from matplotlib, where i use pyplot.scatter(x,y,z, c= Pressure_array) but it leaves me with an artefact like the one shown below (image shows a zoomed in portion of the entire plot)
Notice the fringe like circular pattern. This arises because a Cartesian grid is sampled by a spherical surface and the same is plotted by the scatter points. This pattern remains even upon interpolation of the color values
I am looking for an alternative to the scatter plot method where the surface will be smoother and the circular fringes will be absent. I am aware that matplotlib has surface plots, but i am unable to use it because there, the 'z' coordinate sets both, the height of the plot in 3D and essentially the Color of the surface as well.
Any alternative to scatter plot or surface plot, or a way to get the same domne with the surface plot function in matplotlib will be much appreciated.
On the web, the only solution I find to plot the values of a two-dimensional function is to have a file with the matrix A(nxm) of the function's values and use matplotlib imshow. This will produce a map, whose extent (dimension along axes) has to be known and explicitly indicated.
Now, my concern arises from the fact that I need to plot two maps on the same axis, but one is slanted with respect to the other. So to say, I have a large main rectangular map and a smaller one that is oblique and superimposed.
In the end, the question is: is it possible to plot 2d maps starting from a file that is written as x, y, f(x,y) rather than just using f(x,y) so the plotting tool knows exactly where to draw?
I luckily found what I was looking for in pcolormesh that can draw a map given the coordinates of each point and its "colour"-value.
I do I plot a "continuous", moving plot in Pygame, like the plot in this "NetLogo" simulation? My main difficulty is not the plotting itself (lines between points) but the process of moving the framework of the plot when the curve getting close to the edge of the box.
Thank you.
Ok, so you can make a plot similar to the one in the application in the following way:
create a surface of the size of the graph. Then create a pixel array, so you will be able to modify the graph.
pxarray = pygame.PixelArray (surface)
you can then manipulate the array like any other array:
pxarray[x][y] = 0xFF00FF # this will set pixel at x,y to purple
you can normally then normally blit the surface to the screen.
more on pixel arrays : http://www.pygame.org/docs/ref/pixelarray.html
EDIT: Using pxarray, and transform you will have a shrinking graph if your numbers go out of range. Simply when the point is too big for the plot, you add enough rows, and use transform.scale to scale back to the original resolution.