X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 18 Apr 2019 08:15 AM by  Rajeev Bhattarai
Adding a smooth line through the plotted lines
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Rajeev Bhattarai



New Member


Posts:11
New Member


--
27 Mar 2019 01:39 PM
    Hi,
    I am a beginner in IDL. Can anyone tell me the code for creating a smooth curve through the plotted point data?
    Thanks in advance.

    Ben Castellani



    Basic Member


    Posts:130
    Basic Member


    --
    15 Apr 2019 04:53 PM
    Hello there,

    IDL has many options to perform mathematical curve fitting. The tool most appropriate will depend on your data. Here is a link to all the options: https://www.harrisgeospatial.com/docs/routines-47.html

    Below I have included a simple example using LINFIT, great for creating a "line of best fit" for your plotted data.

    ======

    ;create 2D data
    x = findgen(200)/2.
    y = 8*sin(x)+x

    ;create a line of best fit for your data using LINFIT
    coeffs = linfit(x,y)
    line = coeffs[1]*x+coeffs[0]

    ;create plots of data (x's) and linear fit (red line)
    p = plot(x,y,linestyle=6,symbol='x')
    p2 = plot(x,linear_fit,color='red',linestyle=2,/overplot,thick=2)

    ======

    Rajeev Bhattarai



    New Member


    Posts:11
    New Member


    --
    18 Apr 2019 08:15 AM
    Thank you
    You are not authorized to post a reply.