#51 Correction to psym=10 behaviour in plots

closed-accepted
nobody
None
5
2012-09-16
2012-09-14
sachahony
No

This contains two small corrections to the way the values of the
intersections in a histogram plot (psym=10) are being calculated.

The first one is to use linear spacing when xlog is not
set and logarithmic when it is.

The second correction makes sure we use the difference between two
consecutive points for calculating their logarithmic middle point to
avoid frequent float overflows of the form pow(10,x)

Discussion

  • Alain C.

    Alain C. - 2012-09-16

    thanks for the patch, it is now in the CVS.
    I copy below some details I received by Sacha on the problem.

    Please post a bug report with details if side effects.

    Alain

    I found out about the problem when doing the following:

    x=dindgen(1000)+1

    plot,x
    ;; this works fine

    plot,x,psym=10
    ;; this shows only the histogram until 301 after which the pow(10.,302.)
    ;; overflows and no more data are shown

    plot,x,psym=10,/xlog
    ;; this works but it uses the linear spacing (unlike IDL)

    my patch did not change the equation for calculating the "middle point"
    (val) between x1 and x, I only rewrote it to avoid the large arguments to
    pow(10.,)

    val = log10( (10^x1 + 10^x)/2 ) = log10( 10^x1 * (1 + (10^x)/(10^x1))/2 )
    = x1 + log10( 0.5 + 0.5 * 10^(x-x1) )

    This works until the distance between points to plot exceeds 300 in which
    case 10^(x1-x) would still overflow.

    It would be even better to use the following equation:

    val=pow(10.,(log10(x1)+log10(x))/2.0);

    However this does not work (for a reason I do not understand) in case 0<x1<=1

    for example the first bin of
    plot,dindgen(10)+1,dindgen(10)+1,/xlog,psym=10
    is incorrect

    And this can be seen even clearer if we use points in the interval 0<x<1

    plot,(dindgen(10)+1)/10,dindgen(10)+1,/xlog,psym=10

    HTH,

    Sacha Hony

     
  • Alain C.

    Alain C. - 2012-09-16
    • status: open --> closed-accepted
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks