0

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)

enter image description here

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.

  • I am not sure that this will get rid of the interference pattern but it is not true that in surface plots the z-value determines the color. For examples, see [here](https://stackoverflow.com/a/40452621/8881141) or [here](https://stackoverflow.com/a/40452621/8881141). – Mr. T Jan 24 '22 at 15:42
  • @Mr.T Yes, thank you for the suggestion, I have seen some similar plots before where you cast the array you want to color by as `cm.(Array)` but the problem with this is I cannot seem to get the coloubar right as the Array is then normalised to 0 to 1 and thus the colorbar has the limits (0,1) and not the original values of `Array` – noobprogrammer Jan 25 '22 at 16:49
  • This problem can be solved by normalizing the data to the range (vmin, vmax). The specifics depend on your actual code but the general approach can be seen [for instance here for a bar plot](https://stackoverflow.com/a/65095529/8881141). You simply map your range of values to the range (0, 1) - just an additional step. However, this may still lead to interference patterns, we don't know without your actual code. – Mr. T Jan 25 '22 at 17:07

0 Answers0