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:
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
Plotting Cumulative Counts in Ggplot2
Does R Leverage Simd When Doing Vectorized Calculations
Dynamic Height and Width for Knitr Plots
How to Create a Raster from a Data Frame in R
Create a 24 Hour Vector with 5 Minutes Time Interval in R
How to Screenshot a Website Using R
Modify Variable Within R Function
Matrix Expression Causes Error "Requires Numeric/Complex Matrix/Vector Arguments"
How to Upload a File to a Server via Ftp Using R
What's My User Agent When I Parse Website with Rvest Package in R
Geom_Point() and Geom_Line() for Multiple Datasets on Same Graph in Ggplot2
Fixing Set.Seed for an Entire Session
Calculate Rolling Correlation Using Rollapply
Plot Circle with a Certain Radius Around Point on a Map in Ggplot2