How to detect fluctuations in point cloud height - python

I intercepted the point cloud in one direction and represented it within two-dimensional coordinates. As shown in the figure, it is the curve presented by the z-axis of the point cloud (y-axis in the figure) and the y-axis (x-axis in the figure).
I would like to detect fluctuations in the z-axis range, but I don't currently have a viable method in mind. Because, the number of peaks and valleys in it are uncertain and the fluctuations are also uncertain. I would like to plot my heights like this.
I tried to use clustering, but it was difficult. Is there a good way to do this please? Thanks!

Related

How do you find the coordinates of a plane with a minimized distance strictly above a 3D dataset (python)?

As the title states, I need to make a plane above a 3D dataset in Python. There should be no data points above such plane, and the distances between the plane and the dataset should be optimized such that the plane somehow generalizes the whole data.
this is the 3d surface plot
(this is another example) the plane should look like this
I've been stuck for months on how to start/approach this problem. Should I start looking for the maximums in the data? Should I start on finding the peak in the middle and tamper around the possible slopes of the plane? Or are there other appropriate mathematical methods for this?
Thanks ahead.

Plot the probability density function in a way that the output can be a smooth curve

I am trying to plot the pdf of a dataset in a way that the pdf appears as a smooth curve.
For that, I was using seaborn.kdeplot. The problem with this is - the dataset has a strict range, and the KDE plot tends to cross the range at both edges. To limit the pdf curve within the range I tried to use the clip parameter, but it makes the edges abrupt, not a smooth starting and ending. The abrupt changes at the ends do not look good visually, therefore, I am looking for other ways to plot the pdf.
Could you please provide some insights on this issue? Is there any other way that I can plot the pdf?
As an example, pls find the following code:
data = np.random.uniform(0,1,100)
sns.kdeplot(data)
sns.kdeplot(data, clip=(0, 1))

Plotting 3D Chessboard/Swiss Cheese Type Patterns in Python

My particular case is that I am trying to make a 3D space-time diagram of a 2D cellular automata. If anybody has any advice/clever ways of representing this visually that would be awesome, but to make the question more general I'll phrase it as...
What is the best way to plot a sort of 3D chessboard or Swiss Cheese type pattern where the white squares are transparent (or vice versa)?
I have looked around and have found ways to plot Imshow type plots on a 3D coordinate system, but it was kind of clunky, slow, and I couldn't get the transparency to work (didn't try masks, but it didn't seem like what I wanted, but I could be wrong).
I have also used a scatter plot where I have a point at (x,y,z) if cell (x,y) is in the active state at time z (also tried the other way around...). This actually managed to render and looked pretty cool, but for the wrong reasons since it was hard to see anything on and was hard to angle properly due to the amount of points on the scatter plots making it lag.
Thanks in advance for any advice.

Efficiently drawing lines using python

I am trying to work out an efficient way of drawing line patterns on a screen using python.
A while ago I cobbled together some code that could drive a LAser Spirograph. Which is basically 3 circles each rotating around a moving point of the circumference of each other. This produces a series of point that trace out various patterns depending on the relative speeds each of the circles are spinning.
So now i have a long list of x,y cord that I want to plot as a single line, is there a function in python (currently playing with Pygames) that will take a series of points and conect them with a smooth curved line.
for example say i have a few hundred point that describe the pattern in this link, is there a "simple" way in Python to render he full pattern to screen. I am assuming this would be faster than trying to plot each of several thousand points to get the appearance of a line.
EDIT
I have been assuming that there would be a faster way to draw say a semi circle to the screen by passing a function the start and end point plus the radius. rather than calculate 2,000 points on the curve and plotting them separately either as points or short straight lines. I also am assuming its quicker to plot a straight line 100 points long than outputting the same line as separate points?
Disclaimer This is not an answer
To expand on my comment above
You don't want the curve. You want to sample the curve with a frequency sufficient to fool perception
have a look at the effects of denser vs coarser sampling on the perception of what is drawn on a screen
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0, np.pi*3, 301)
x = np.sin(t)
each of the points (t[i], x[i]) represent a point, here a pont in a sine curve, in your application a more complex curve, so let's plot these points using a different sampling step, to see if the sampling rate has an effect on your perception of what is drawn...
for step in (1, 25, 50):
plt.plot(t[::step], x[::step], label='step=%d'%step)
# ^^^^ ^^^^
plt.ylim((-1.05, 1.05))
plt.legend(loc='best')
that gives me
I dare say, with a sufficiently high sampling rate what is drawn looks like a curve, even if it is a sequence of straight segments (as it's apparent when you look at the other two istances of t vs x).
In other comments, you were told which pygames function you can use to do your deed.

Python: how to plot points with little overlapping

I am using python to plot points. The plot shows relationship between area and the # of points of interest (POIs) in this area. I have 3000 area values and 3000 # of POI values.
Now the plot looks like this:
The problem is that, at lower left side, points are severely overlapping each other so it is hard to get enough information. Most areas are not that big and they don't have many POIs.
I want to make a plot with little overlapping. I am wondering whether I can use unevenly distributed axis or use histogram to make a beautiful plot. Can anyone help me?
I would suggest using a logarithmic scale for the y axis. You can either use pyplot.semilogy(...) or pyplot.yscale('log') (http://matplotlib.org/api/pyplot_api.html).
Note that points where area <= 0 will not be rendered.
I think we have two major choices here. First adjusting this plot, and second choosing to display your data in another type of plot.
In the first option, I would suggest clipping the boundries. You have plenty of space around the borders. If you limit the plot to the boundries, your data would scale better. On top of it, you may choose to plot the points with smaller dots, so that they would seem less overlapping.
Second option would be to choose displaying data in a different view, such as histograms. This might give a better insight in terms of distribution of your data among different bins. But this would be completely different type of view, in regards to the former plot.
I would suggest trying to adjust the plot by limiting the boundries of the plot to the data points, so that the plot area would have enough space to scale the data and try using histograms later. But as I mentioned, these are two different things and would give different insights about your data.
For adjusting you might try this:
x1,x2,y1,y2 = plt.axis()
plt.axis((x1,x2,y1,y2))
You would probably need to make minor adjustments to the axis variables. Note that there should definetly be better options instead of this, but this was the first thing that came to my mind.

Categories