Plotting a Curve Around a Set of Points

Plotting a set of given points to form a closed curve in matplotlib

If you don't know how your points are set up (if you do I recommend you follow that order, it will be faster) you can use Convex Hull from scipy:

import matplotlib.pyplot as plt
from scipy.spatial import ConvexHull

# RANDOM DATA
x = np.random.normal(0,1,100)
y = np.random.normal(0,1,100)
xy = np.hstack((x[:,np.newaxis],y[:,np.newaxis]))

# PERFORM CONVEX HULL
hull = ConvexHull(xy)

# PLOT THE RESULTS
plt.scatter(x,y)
plt.plot(x[hull.vertices], y[hull.vertices])
plt.show()

, which in the example above results is this:

Convex hull in a plot

Notice this method will create a bounding box for your points.

How do I fit a curve around a set of points with Octave?

use convhull to find the external envelope to your set

x = rand (1, 30);
y = rand (1, 30);
hold on;
plot (x, y, "r*");
H=convhull(x,y)
plot(x(H),y(H));
axis ([0,1,0,1]);

Ploting a curve around some set of points in Scilab

The plot option *b says "blue asterisks".

If you want "blue asterisks connected by a curve", use *b-

The LineSpec documentation explains all this.

if you specify a marker without a line style, only the marker is drawn.

In your example * is a marker. To also have a line, specify a line style such as -.

Plotting a smoothed area on a map from a set of points in R

One option is to make a polygon bounded by a Bézier curve, using the bezier function in the Hmisc package. However I cannot get the start/end point to join up neatly. For example:

## make some points
p <- matrix(c(50, 50, 80, 100, 70, 40, 25, 60), ncol=2)
## add the starting point to the end
p2 <- cbind(1:5,p[c(1:4,1),])
## linear interpolation between these points
t.coarse <- seq(1,5,0.05)
x.coarse <- approx(p2[,1],p2[,2],xout=t.coarse)$y
y.coarse <- approx(p2[,1],p2[,3],xout=t.coarse)$y
## create a Bezier curve
library(Hmisc)
bz <- bezier(x.coarse,y.coarse)
library(maps)
map('world')
map.axes()
polygon(bz$x,bz$y, col=rgb(0,0,1,0.5),border=NA)

How to draw a curve passing through a set of 2D points using Core Plot library for iOS?

Here's the Google Search i did

Here is the Core-Plot's Own example project: Here

And a Third party Tutorial: Here

Also here is a helpful snippet from the Core-Plot Developers: Here

Hope it helps, btw most people on here will prob tell you to use Google for a simple request like this.

So for future reference when you need an example of an API search in google the following "Insert API Name here" Tutorial, This will usually return at least 1 tutorial in most cases on the first page



Related Topics



Leave a reply



Submit