标签: curves

gnuplot:在y轴上绘制一个包含4列的文件

我有一个包含4个数字(最小值,最大值,平均值,标准推导值)的文件,我想用gnuplot绘制它.

样品:

24 31 29.0909 2.57451
12 31 27.2727 5.24129
14 31 26.1818 5.04197
22 31 27.7273 3.13603
22 31 28.1818 2.88627
Run Code Online (Sandbox Code Playgroud)

如果我有一个列有4个文件,那么我可以这样做:

gnuplot "file1.txt" with lines, "file2.txt" with lines, "file3.txt" with lines, "file4.txt" with lines
Run Code Online (Sandbox Code Playgroud)

它将绘制4条曲线.我不关心x轴,它应该只是一个恒定的增量.

我怎么能请情节?我似乎无法找到一种方法,有4条曲线,1个文件有4列,只有一个不断递增的x值.

谢谢.

gnuplot curves

30
推荐指数
2
解决办法
8万
查看次数

如何通过点制作直线曲线

我正在寻找一种通过多个点制作直线曲线的方法.最好使用3个点,尽管我认为为了给出进入点的线的角度的上下文,可能需要更多来给出曲线的上下文.

通常,起点P1,控制点P2和终点P3,该线应从P1弯曲到P2,然后从P2到P3弯曲.

事实上,这是我希望实现的效果的完美示例:

Irwin Hall Spline

如果我能做到这一点,我真的会永远感激!

到目前为止,在Java中,我尝试过使用QuadCurve2D.Double,Cub icCurve2D.Double以及Path2D.Double(使用带有Path2D.Double的curveTo)之类的东西,但无济于事 - 绘制的曲线甚至不接近通过指定的控制点.

这是我到目前为止尝试的方法的图像:

在此输入图像描述

这是我用来生成图像中的点和曲线的代码:

    Graphics2D g = (Graphics2D) window.getGraphics();
    g.setColor(Color.blue);
    int d = 4;

    // P0
    int x0 = window.getWidth()/8;
    int y0 = 250;
    g.drawString("P0", x0, y0 + 4*d);
    g.fillRect(x0, y0, d, d);

    // P1
    int x1 = (window.getWidth()/7)*2;
    int y1 = 235;
    g.drawString("P1", x1, y1 + 4*d);
    g.fillRect(x1, y1, d, d);

    // P2
    int x2 = (window.getWidth()/2);
    int y2 = 200;
    g.drawString("P2", x2, y2 - 2*d);
    g.fillRect(x2, …
Run Code Online (Sandbox Code Playgroud)

java awt splines curves

10
推荐指数
1
解决办法
1万
查看次数

如何将文本转换为路径?

我试图将文本转换为曲线和路径,例如:

Text ='欢迎来到python'

我正在尝试将此文本转换为路径.此外,我试图将此路径信息作为点列表.

我想将文本存储为SVG文件中的路径.

就像在adobe illustrator中将文本转换为轮廓时一样.

我试过这个例子,但这不是我想要的: cairo例子

import cairo

def text_extent(font, font_size, text, *args, **kwargs):
    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 0, 0)
    ctx = cairo.Context(surface)
    ctx.select_font_face(font, *args, **kwargs)
    ctx.set_font_size(font_size)
    return ctx.text_extents(text)

text='Example'
font="Sans"
font_size=55.0
font_args=[cairo.FONT_SLANT_NORMAL]
(x_bearing, y_bearing, text_width, text_height,
 x_advance, y_advance) = text_extent(font, font_size, text, *font_args)
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(text_width), int(text_height))
ctx = cairo.Context(surface)
ctx.select_font_face(font, *font_args)
ctx.set_font_size(font_size)
ctx.move_to(-x_bearing, -y_bearing)
ctx.text_path(text)
ctx.set_source_rgb(0.47, 0.47, 0.47)
ctx.fill_preserve()
ctx.set_source_rgb(1, 0, 0)
ctx.set_line_width(1.5)
ctx.stroke()

surface.write_to_png("/tmp/out.png")
Run Code Online (Sandbox Code Playgroud)

python text path curves

10
推荐指数
1
解决办法
1921
查看次数

python曲线的距离矩阵

我有一组定义为2D数组的曲线(点数,坐标数).我正在使用Hausdorff距离计算它们的距离矩阵.我目前的代码如下.不幸的是,它太慢,有500-600条曲线,每条曲线有50-100个3D点.那有更快的方法吗?

def distanceBetweenCurves(C1, C2):
    D = scipy.spatial.distance.cdist(C1, C2, 'euclidean')

    #none symmetric Hausdorff distances
    H1 = np.max(np.min(D, axis=1))
    H2 = np.max(np.min(D, axis=0))

    return (H1 + H2) / 2.

def distanceMatrixOfCurves(Curves):
    numC = len(Curves)

    D = np.zeros((numC, numC))
    for i in range(0, numC-1):
        for j in range(i+1, numC):
            D[i, j] = D[j, i] = distanceBetweenCurves(Curves[i], Curves[j])

    return D
Run Code Online (Sandbox Code Playgroud)

python numpy distance scipy curves

9
推荐指数
2
解决办法
4017
查看次数

如何找到两条曲线之间的相似性和相似度得分?

我有两个数据集(t,y1)和(t,y2).这些数据集在视觉上看起来相同,但它们是一些时间延迟或幅度变化.我想找到两条曲线之间的相似性(给出近似相似曲线的相似度1得分,不相似曲线得出0).由于数据的振荡,一些曲线似乎不同.所以,我正在寻找找到曲线之间相似性的方法.我已经尝试在Matlab中使用渐变命令来找到每个时间步长的曲线斜率并进行比较.但它没有给我满意的结果.请有人建议我找到曲线之间相似性的方法.

提前致谢

在此输入图像描述

matlab time-series similarity curves

7
推荐指数
2
解决办法
1万
查看次数

Python使用numpy曲线与fsolve()和函数参数交叉

我试图在这里引用fsolve:http://glowingpython.blogspot.gr/2011/05/hot-to-find-intersection-of-two.html,

为了找到两条曲线之间的交点.两条曲线基本上都是两个浮点数组.

第一个是一维数组Pmech ( Pmech(x) ),第二个是二维数组Pair ( Pair(x,y) )

x轴对于两个阵列都是通用的,所以我想要做的是每个y看到Pair和Pmech相交的位置.

我知道fsolve()作为参数函数,而不是数组,所以我写了两个基本函数来实现这个功能:

def Pmix(x):
    return Pmech[x]

def Paera(x,y):
    return Pair[x,y]
Run Code Online (Sandbox Code Playgroud)

所以我在上面的链接中演示了我实现的findIntersection功能:

def findIntersection(fun1,fun2,x0): 
    return fsolve(lambda x: (fun1(x) - fun2(x,y) for y in range(1,100)),x0)
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

TypeError: float() argument must be a string or a number
Traceback (most recent call last):
  File "batteries.py", line 261, in <module>
    findIntersection(Pmix,Paera,0)
  File "batteries.py", line 238, in findIntersection
    fsolve(lambda x: (fun1(x) - fun2(x,y) for y in …
Run Code Online (Sandbox Code Playgroud)

python numpy intersection curves

6
推荐指数
1
解决办法
6133
查看次数

如何在ZedGraph中引入特定曲线

在绘制两条曲线后,我在zedgraph控件上有两条曲线......

PointPairList thresholdList = new PointPairList();
PointPairList powerList = new PointPairList();

private void plotPower()
{
        // Create an object to access ZedGraph Pane
        GraphPane pane = zedGraphControl1.GraphPane;            
        LineItem thresholdLine = new LineItem("thresholdLine");
        LineItem powerLine = new LineItem("powerLine");

        // Set the Threshold Limit
        double thresoldLimit = Convert.ToDouble(numAnalysisThreshold2.Value);

        // Points
        double[] x = new double[]{0, pane.XAxis.Scale.Max};
        double[] y = new double[]{thresoldLimit, thresoldLimit};

        // Set the threshold line curve list
        thresholdList.Add(x, y); 

        // Set the Power Line curve list
        powerdList.Add(XData, YData);

        // Add …
Run Code Online (Sandbox Code Playgroud)

c# plot zedgraph curves

5
推荐指数
2
解决办法
5306
查看次数

如何在Matlab中获得图像中存在的n条曲线的长度?

目前我一直在努力获取曲线的长度,我已经设法使用以下代码来获得图像中存在的曲线长度.

测试图像一条曲线

然后我粘贴我用来获取简单图像曲线长度的代码.我做的是以下内容:

  1. 我得到了图像的列和行
  2. 我得到了x中的列和y中的行
  3. 我根据比喻的公式获得了曲线的系数
  4. 建立方程式
  5. 实施弧长公式以获得曲线的长度

    grayImage = imread(fullFileName);
    [rows, columns, numberOfColorBands] = size(grayImage);
    if numberOfColorBands > 1
      grayImage = grayImage(:, :, 2); % Take green channel.
    end
    subplot(2, 2, 1);
    imshow(grayImage, []);
    
    % Get the rows (y) and columns (x).
    [rows, columns] = find(binaryImage);
    
    coefficients = polyfit(columns, rows, 2); % Gets coefficients of the    formula.
    
    % Fit a curve to 500 points in the range that x has.
    fittedX = linspace(min(columns), max(columns), 500);
    
    % Now get the …
    Run Code Online (Sandbox Code Playgroud)

matlab image curves

5
推荐指数
1
解决办法
418
查看次数

抛物线与线段的交点

我有一个与指定点相交的抛物线曲线的等式,在我的情况下,用户点击图形.

 // this would typically be mouse coords on the graph
 var _target:Point = new Point(100, 50);

 public static function plot(x:Number, target:Point):Number{
  return (x * x) / target.x * (target.y / target.x);
 }
Run Code Online (Sandbox Code Playgroud)

这给出了如下图:

抛物线

我还有一系列由开始和结束坐标定义的线段:

startX:Number, startY:Number, endX:Number, endY:Number
Run Code Online (Sandbox Code Playgroud)

我需要找到此曲线与这些段相交的位置(A):

替代文字

如果有任何帮助,startX总是如此< endX

我觉得有一个相当直接的方法来做到这一点,但我真的不知道要搜索什么,也不是我非常精通"正确"的数学,因此非常感谢实际的代码示例.

更新:

我有交叉点工作,但我的解决方案给了我y轴错误侧的坐标.

分别用A和B替换目标坐标,给出了该图的等式:

(x * x) / A * (B/A)

// this simplifies down to:
(B * x * x) / (A * A)

// which i am the equating to the line's equation …
Run Code Online (Sandbox Code Playgroud)

language-agnostic math geometry actionscript-3 curves

4
推荐指数
1
解决办法
2501
查看次数

B样条曲线

我有一组要使用 B 样条曲线平滑的点。
我的问题是如何实现 B 样条曲线来平滑这些点集?
我想使用 C++ 来实现这一点。

c++ splines curves bspline

4
推荐指数
1
解决办法
1万
查看次数