Menu

#220 Auto-ordering of forecast intervals in gnuplot command

None
closed
nobody
None
4
2025-02-24
2024-11-20
No

Summary

Enhancement request for the gnuplot command to automatically order multiple forecast intervals based on their confidence levels (factors) when plotting, ensuring proper visualization of nested intervals.

Current Behavior

When plotting multiple forecast intervals using the --bands option, the order of intervals in the bundle array determines their plotting order. This can lead to visualization issues where wider intervals completely cover narrower ones if not manually ordered correctly.

Please find attached a sample script.

Example of Current Issue

# This ordering causes the 80% interval to be invisible
bundles Bands = defarray(FC_INTVAL_CI_80, FC_INTVAL_CI_95)
gnuplot LRY fc --with-lines --time-series --bands=Bands --output=display

Proposed Solution

Implement automatic ordering of intervals based on their factor values in descending order. This would:

  1. Sort intervals automatically: Wider intervals (larger factors) would be plotted first, followed by narrower ones
  2. Make ordering irrelevant: Users wouldn't need to manually arrange intervals
  3. Ensure consistent visualization: All intervals would be visible regardless of input order

Implementation Details

  1. Add a sorting mechanism that:
  2. Extracts factor values from each bundle in the bands array
  3. Sorts bundles in descending order based on factors
  4. Applies the sorted order when plotting

  5. Example of desired behavior:

# Both orderings would produce identical plots
bundles Bands = defarray(FC_INTVAL_CI_80, FC_INTVAL_CI_95)
# or
bundles Bands = defarray(FC_INTVAL_CI_95, FC_INTVAL_CI_80)

Benefits

  • Prevents user errors in interval visualization
  • Simplifies code by removing the need to manually order intervals
  • Ensures consistent and correct display of nested confidence intervals
1 Attachments

Discussion

  • Sven Schreiber

    Sven Schreiber - 2024-11-20

    Don't you just need the 'asort' function before passing your stuff to gnuplot?

     
    • Artur Tarassow

      Artur Tarassow - 2024-11-20

      Personally, I haven't used asort() before . But yes, it looks like this can handle the sorting part. This, of course, would require an additional step to do by the user. It took me 1,5 days to understand the cause of "hidden" intervals.

      That's why I suggest an automatic sorting done by Gretl itself in the background.

      By the way, let me also provide an alternative which helps somehow: Using gnuplot's option to set the alpha channel (transparency level) which gretl supports since some time.

      Try the color strings color="#99FF8E1E" and color="#99F52D12" which avoids the overlapping somehow.

       
  • Sven Schreiber

    Sven Schreiber - 2025-02-24
    • status: open --> closed
    • Group: -->
     
  • Sven Schreiber

    Sven Schreiber - 2025-02-24

    I was going to argue some more that it really could be left to the user, but some testing and further digging revealed that this was actually already implemented back in November, see https://sourceforge.net/p/gretl/git/ci/b98556db85d8b3c2a89f07b65232bc045e312b84/.
    Artur's test case works in the sense that with gretl 2024d nothing is covered anymore. So I'm closing this.

     

Log in to post a comment.

MongoDB Logo MongoDB