Converting 2D Plot to 3D - python-3.x

I'm looking to make do the following with my 2D graph as shown: I want to make a surface plot of gamma vs. J vs h. However I am not sure how to incorporate h. gamma and J are arrays made up of 26 points each. How do I make h fit into this plot if it only has one specific value for each plot?

in my final paper I needed to create a 3d graph, on this occasion the graph was a cross of latitude, longitude and radioactive intensity. I used the plotly, check if it's help you plotly documentation.
My graph created with this biblioteca

Related

Making Elevation-distance plot

I have some latitude and longitude of some points. I want to make an Elevation-distance plot using python. I have a code which can plot elevation vs distance plot between two points, but doesn't know how to make if there is more than one point?
Note these points are not in a Straight line.
https://www.geodose.com/2018/03/create-elevation-profile-generator-python.html

How to convert x and y coordinates into a heat map in excel?

I currently have a data set of x and y coordinates (position of an animal in an arena) over a period of time. I just used the coordinates to plot a scatter plot of what that looks like. However, instead of having every single coordinate as a separate point, i was wondering if there was a way to create a heat map of the points? So, the higher the likelihood of the animal in a specific area/ similar coordinates, the warmer the color? Hoping for the final product to be a depiction of the arena with a gradient of colors based on the likelihood the animal explores those regions?
Well with that many points, I don't know if Excel is the right choice if wanting to color-coordinate. The site https://app.rawgraphs.io/ has some really cool graphing capabilities. I use this when needing sankey's or something unusual that Excel cannot easily handle.
Here I used 1500 x/y points between 0 and 20. Then I selected the graph type called "Contour Plot".
Would this work?
Or here's a Hexagonal Binning chart of the same data...

Gnuplot Plotting Multiple Interpolated Surfaces in One Image

I am trying to visualize results from varying three different parameters using gnuplot. I can produce a 4D plot by using an xyz scatter plot with color as the fourth dimension. Now what I want to do is to take the limited data I have and produce higher quality images. As seen below, if I angle the 4D plot in just the right way I can get what looks like a series of 3D plots along one dimension. Is there a way I can individually interpolate these 3D slices and obtain smoothed planar surfaces for the cross-sections instead of the scatter plot form I currently have?
4D Scatter Plot Angled to Look Like 3D Cross-Sections:
New in version 5.4 (please try and report on the release candidate!)
http://gnuplot.sourceforge.net/demo_5.4/voxel.html

How to represent density information on a matplotlib 3-D scatter plot

I am trying to plot the r,g,b channels in an image as a 3-D scatter plot.
This works well when i have a black and white image as i get a scatter plot with just two distinct clusters at two ends of the scatter plot.
However for color images the scatter plot does not make much sense visually because there are r,g,b values corresponding to many points in the color space in the image.
So i end up with something like the image shown below -
What i would like to achieve is somehow represent density information. For example if the number of points corresponding to (255,255,255) are 1000 and the number of points corresponding to (0,0,0) are only 500 then i want (255,255,255) to be dark red and (0,0,0) to be yellow/orangish
How do i achieve this in matplotlib? I am okay with some sort of bubble effect as well where the (255,255,255) is represented as a bigger bubble compared to (0,0,0) although i feel density information encoded as color information would be more visually appealing
Here's an attempt using Gaussian KDE. It's still far from perfect and the result largely depends on the estimation parameters (bw_method). There is perhaps a simpler way, maybe something using np.unique to get the frequency of each unique colour.
The idea is to estimate color density distribution as a multivariate gaussian mixture and use that as a colormap for the scatter plot.
It's a bit slow for anything serious but I think it gives nice results with small enough images. Maybe some FFT+convolution based estimation method could be faster.
Let's see some code. Nothing fancy: it flattens and reshapes image data the way gaussian_kde likes it and return RGB and density components. You can play with bw_method and see how the results change, the bigger, the smoother density you'll get.
from scipy.stats import gaussian_kde
def img_to_rgbk(img, bw=0.1):
rgb = img.reshape(-1, 3).T
k = gaussian_kde(rgb, bw_method=bw)(rgb)
r, g, b = rgb
return r, g, b, k
Here's the results with a toy image
img = chelsea()[100:200, 100:200]
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
r, g, b, k = img_to_rgbk(img, bw=0.5)
ax.scatter(r, g, b, c=k, alpha=0.2)
Notice c=k is used to set map marker color to the density information, alpha is needed to see a bit through the cloud.
Chelsea
Random colors
Gradient
Note here you can see how the wrong choice of bandwidth can be misleading. A small enough bw_method should reveal essentially a single color per column, repeated along rows. So every dot should have the same color (and it will with the right bandwidth).
Gradient + noise
Here with a better bandwidth and some noise to spread the colors. Notice the bigger density around the white-ish area where the discontinuity in the no-noise plot becomes a density maximum.

How can I plot the points of a curve?

I'm not great with Math at all and so-so with Excel. I have a requirement to calculate a series of values to apply as an offset for a price schedule. I know what I basically want to achieve with the offsets and how I want them to change across span of values but I don't know how I can plot these values or something close to it in Excel. For an idea of the curve I'm roughly trying to create you can plot these values:
0
20
30
35
38
39
39.5
40
40.5
40.75
41
41.125
41.25
Or if you don't want to use excel you can take a look at this chart image:
Now it was easy to quickly create that by entering some values and tweaking them to get a shape I roughly want, but I need 1000 data points! In other words, instead of the 13 point I provided above I would need 1000. This would be crazy to try and do manually.
I can think of two possible options:
Create the range of values with fewer points, then somehow
extrapolate that data set into more points. Maybe extrapolate isn't
correct but essentially convert 10 points of data into 1000
Interactively draw a curve and then have it plotted to values within
a defined min/max range
I've tried googling for help but I'm just coming up with tons and tons of "how to plot your data" sites - I need to work from the OTHER direction ;)
Thanks for any help or tips.
Like you said, you could draw a curve and plot those points, then put them into some equation solver to get an equation that could describe the curve you're looking for.
But just from looking at your curve above, you might be able to use an equation of the following form.
y = A - (B / x)
To make a curve similar to yours above, you might try...
y = 40 - (5 / x))
You can use a site like https://functionplotter.com/ to plot the function and play with the values of A and B until you have curve that you are satisfied with.
Is this kind of thing you are looking for?
spline interpolation in exel
XlXtrFun.xll
basically you already got 13 y's and 13 implict x's (1 to 13). You provide bunch of "x" values of small increment, like 0.01, 0.02, 0.03, ...,12.999 13.000, to this tool. then this tool will calculate y value for each of the ones. You will plot these as "x y scatter plot"
A simple and very accurate way is to plot the curve as an x-y scatter plot, and then fit a polynomial via Insert Trendline.
In this case a 4th order polynomial provides close to a perfect fit (R2 of .9973)
Y = -0.0139x4 + 0.4819x3 - 6.0607x2 + 33.026x - 26.718
You can also solve this without charts using LINEST, see Walkenbach's guide here. But charts provide the easiest reference

Resources