log log scale scatterplot [message #94907] |
Tue, 05 December 2017 10:21  |
gunvicsin11
Messages: 93 Registered: November 2012
|
Member |
|
|
Hello all,
I need to plot in log log scale and it is a scatter plot and I need to get the slope and intercept after fitting with linfit. This needs to be plotted in logarithmic space. And also the correlation coefficient needs to be calculated in log-log space.
I have 10 x values and 10 y values
is this correct plot, alog10(x), alog10(y)
or like this plot, x,y,/xlog,/ylog but I need the values in order to find the linfit.
how to do this
thanks
|
|
|
Re: log log scale scatterplot [message #94908 is a reply to message #94907] |
Tue, 05 December 2017 13:34   |
benjamin.castellani
Messages: 7 Registered: October 2017
|
Junior Member |
|
|
On Tuesday, December 5, 2017 at 11:21:27 AM UTC-7, sid wrote:
> Hello all,
> I need to plot in log log scale and it is a scatter plot and I need to get the slope and intercept after fitting with linfit. This needs to be plotted in logarithmic space. And also the correlation coefficient needs to be calculated in log-log space.
>
> I have 10 x values and 10 y values
> is this correct plot, alog10(x), alog10(y)
> or like this plot, x,y,/xlog,/ylog but I need the values in order to find the linfit.
>
> how to do this
> thanks
Here is a sample code that does what you need it to do:
;example data (5 points)
x = [1487,500,24,3455,2233]
y = [11,50,2400,32.3,111]
fit = linfit(alog(x),alog(y))
xfit=[0:max(alog(x)):max(alog(x))/100.]
yfit = xfit*fit[1]+fit[0]
p = plot(alog(x),alog(y),layout=[2,1,1],symbol='o',linestyle=6,c olor='blue')
p2 = plot(xfit,yfit,/overplot)
NOTE: You can use either of your plot techniques. This will just change the actual labels on the axes. One will be just the log powers (it will show 3 for 1000), the other will be the data values in log form (it will show 10^3 for 1000)
|
|
|
Re: log log scale scatterplot [message #94909 is a reply to message #94907] |
Tue, 05 December 2017 13:49   |
benjamin.castellani
Messages: 7 Registered: October 2017
|
Junior Member |
|
|
On Tuesday, December 5, 2017 at 11:21:27 AM UTC-7, sid wrote:
> Hello all,
> I need to plot in log log scale and it is a scatter plot and I need to get the slope and intercept after fitting with linfit. This needs to be plotted in logarithmic space. And also the correlation coefficient needs to be calculated in log-log space.
>
> I have 10 x values and 10 y values
> is this correct plot, alog10(x), alog10(y)
> or like this plot, x,y,/xlog,/ylog but I need the values in order to find the linfit.
>
> how to do this
> thanks
x = [1487.,500,24,3455,2233]
y = [11,50,2400,32.3,111]
fit = linfit(alog(x),alog(y))
xfit=[min(alog(x)),max(alog(x))]
yfit = xfit*fit[1]+fit[0]
p = plot(alog(x),alog(y),symbol='o',linestyle=6,color='blue',sym _filled=1)
p2 = plot(xfit,yfit,/overplot)
t = text(0.5,0.8,/normal,'Y = ' + strtrim(string(fit[1]),2) + ' X + ' + strtrim(string(fit[0]),2),color='red')
|
|
|
Re: log log scale scatterplot [message #94916 is a reply to message #94909] |
Wed, 06 December 2017 22:42  |
gunvicsin11
Messages: 93 Registered: November 2012
|
Member |
|
|
On Wednesday, December 6, 2017 at 3:19:50 AM UTC+5:30, Ben Castellani wrote:
> On Tuesday, December 5, 2017 at 11:21:27 AM UTC-7, sid wrote:
>> Hello all,
>> I need to plot in log log scale and it is a scatter plot and I need to get the slope and intercept after fitting with linfit. This needs to be plotted in logarithmic space. And also the correlation coefficient needs to be calculated in log-log space.
>>
>> I have 10 x values and 10 y values
>> is this correct plot, alog10(x), alog10(y)
>> or like this plot, x,y,/xlog,/ylog but I need the values in order to find the linfit.
>>
>> how to do this
>> thanks
>
> x = [1487.,500,24,3455,2233]
> y = [11,50,2400,32.3,111]
>
> fit = linfit(alog(x),alog(y))
> xfit=[min(alog(x)),max(alog(x))]
> yfit = xfit*fit[1]+fit[0]
>
>
> p = plot(alog(x),alog(y),symbol='o',linestyle=6,color='blue',sym _filled=1)
> p2 = plot(xfit,yfit,/overplot)
> t = text(0.5,0.8,/normal,'Y = ' + strtrim(string(fit[1]),2) + ' X + ' + strtrim(string(fit[0]),2),color='red')
Thanks a lot for the code.
|
|
|