surfaceplot with matplotlib over points xyz - python

I'm trying to plot a surface over several points it should look like a deformed sphere.
I used the scatter function and plotted the points, but the surface function is not working (the window is empty).
To plot the surface, I think i need a mesh function. I try ed to mash x,y,z but it was not working. How i can generate the code, to put a surface over my points?.
Thanks for helping me.
I have the points xyz stored in a list. They are describing a deformed sphere and i have to plot somthing like this
(source: iop.org)

This question is hard to answer without any sample code of what you're doing, you might want to edit it to include a working example.
I suppose you are using the mplot3d class, have you checked the examples that are provided online here, here, and here? These to me look like what you're trying to produce.

Related

Plottin a profile based on multiple 2D plots in a 3D scenario

So, I have Multiple plots in 2d from an estimative of depth from a basin I'm studying. I want to plot them in a 3D perspective so I can see the connection between them like lined according to their long/lat. I don't know if I can explain. I tried some interpolations methods To plot the layers as a 3d surface terrain, but none of them gave me the results I was looking for. I hope someone can help me.
These are the profiles
And I would like something like this
The data that I have looks like this:

How to plot 3D Earth in Python?

I'm trying to plot a satellite orbit around the Earth. This is what I currrently have:
I made this plot using the Axes3D function in mpl_toolkits.mplot3d. Ideally what I would like to do, is to replace the simple sphere with an actual Earth with topology.
If you're not sure what I mean, take a look at a MATLAB implementation:
http://uk.mathworks.com/matlabcentral/fileexchange/13823-3d-earth-example
The Basemap package could be of help (especially the bluemarble() function), but unforunately I can't make it work on 3D objects. There is a similar question here, but the answer to that question results in a projection of a 3D sphere on a 2D plot. I want a 3D sphere on a 3D plot, so that I'm able to rotate around it.
Does anybody know of another package/implementation. Or is there a way to make Basemap work with 3D objects?
---EDIT---
Somebody asked the same question, but nobody has answered it yet
I have asked something similar some times ago
PyOpenGL sphere with texture
If I were you I would pick a OpenGL and use a texture of Earth on it just like this one
https://i.stack.imgur.com/ojwD8.jpg
In any case there is my second thread where I needed to make a Mars planet which is basically the same as you want except different texture:
Why my texture is not showing PyOpenGL

Plotting multivalued surface in mayavi

mayavi
I have some data which is on a structured grid in the X and Y directions and is unstructured in the Z direction. This is in the form of a list of data points, e.g [[x,y,z], [x2,y2,z2], ...]. There are 2 points corresponding to most x,y coordinates, and the data is double valued in the z dimension. I would like to plot this shape as an enclosed surface, and if possible remove one of the walls.
I have tried the advice here: http://docs.enthought.com/mayavi/mayavi/auto/example_surface_from_irregular_data.html#example-surface-from-irregular-data
When I try this only the bottom half of the plot is covered by the surface. I also get this message which I don' understand: No handlers could be found for logger "mayavi.core.common". I would love to know why this is.
I have tried plotting the top and bottom surfaces separately, but this looks a bit ugly. Here is what that looks like:
matplotlib
I have also tried to grid my data and follow the advice using the matplotlib demos. I can't post the link to this because I don't have the reputation, but if you google matplotlib plot3D demos it is in the first result.
I can't get this to produce anything reasonable. I think this is because I don't really understand how the sphere example on that web page could be adapted to work with data rather than a function.
Question
how can I adapt the code I have from the link I provided to produce a plot of an enclosed surface?
or, how can I use matplotlib to make the enclosed surface?
Or is there some other program/function I ought to be using for this kind of problem?

Best way to create a 2D Contour Map with Python

I am trying to create a 2D Contour Map in Python that looks like this:
In this case, it is a map of chemical concentration for a number of points on the map. But for the sake of simplicity, we could just say it's elevation.
I am given the map, in this case 562 by 404px. I am given a number of X & Y coordinates with the given value at that point. I am not given enough points to smoothly connect the line, and sometimes very few data points to draw from. It's my understanding that Spline plots should be used to smoothly connect the points.
I see that there are a number of libraries out there for Python which assist in creation of the contour maps similar to this.
Matplotlib's Pyplot Contour looks promising.
Numpy also looks to have some potential
But to me, I don't see a clear winner. I'm not really sure where to start, being new to this programming graphical data such as this.
So my question really is, what's the best library to use? Simpler would be preferred. Any insight you could provide that would help get me started the proper way would be fantastic.
Thank you.
In the numpy example that you show, the author is actually using Matplotlib. While there are several plotting libraries, Matplotlib is the most popular for simple 2D plots like this. I'd probably use that unless there is a compelling reason not to.
A general strategy would be to try to find something that looks like what you want in the Matplotlib example gallery and then modify the source code. Another good source of high quality Matplotlib examples that I like is:
http://astroml.github.com/book_figures/
Numpy is actually a N-dimensional array object, not a plotting package.
You don't need every pixel with data. Simply mask your data array. Matplotlib will automatically plot the area that it can and leave other area blank.
I was having this same question. I found that matplotlib has interpolation which can be used to smoothly connect discrete X-Y points.
See the following docs for what helped me through:
Matplotlib's matplotlib.tri.LinearTriInterpolator docs.
Matplotlib's Contour Plot of Irregularly Spaced Data example
How I used the above resources loading x, y, z points in from a CSV to make a topomap end-to-end

Plotting graphs with error ribbons in python

for a while I've been trying to come up with a good way to graphically represent a data series along with its estimated error.
Recently I saw some graphs where the data was plotted as a line, with a background 'ribbon' filling the area between the lines plotting data +/- sigma.
Is there a name for this type of graph, and is there any python toolkit which has the capability to make such plots?
A simple way to fake it with matplotlib would also be useful - right now I'm just plotting three lines, but I don't know how to fill the area between them.
I would use the fill_between method. Look at the Our Favorite Recipes section of the manual for matplotlib for some good examples. They have one that looks like this:
and another that looks like this:

Categories