X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 27 Jun 2007 03:57 PM by  anon
Plot time-series data with scrollbars
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
27 Jun 2007 03:57 PM
    I want to plot time-series data with IDL. My time series typically contain 50,000 points, but can contain up to 500,000 points. I want to plot all these points on a single IDL plot, which of course must be very long in the x-dimension in order to visualize the data. If I use the window() and plot() functions, I can create a window containing a plot that is as many pixels wide as I want (so typically a plot is about 10,000 pixels wide). It's very annoying to have to scroll through the data by clicking on the plot window and moving it. I feel like an idiot doing this. How can I create a plot window with a horizontal scrollbar in it that I can just click to scroll to the next screen width of data? Even better, could I set up the plot to scroll to the next screen width of data by pressing a key on the keyboard (the mouse is evil), such as the "Page Up" and "Page Down" keys, for example? Thanks.

    Deleted User



    New Member


    Posts:
    New Member


    --
    27 Jun 2007 03:57 PM
    Andrew, you can get very manageable scrollbars for very large plot windows in IDL, but you have to implement an IDL widget program to get these. If you are doing nothing but scrolling - i.e., using the mouse on the scroll bar - then the widget program equivalent of WINDOW can be as simple as this: ; Create some demo sine wave data x = findgen(10000) y = (x mod 360) * !DTOR ; The next five calls provide a scrollable substitute for a simple WINDOW call tlb = widget_base(/COLUMN) wDraw = widget_draw(tlb, XSIZE=10000, YSIZE=400, $ ; 10,000 x 400 canvas ... X_SCROLL_SIZE=400, Y_SCROLL_SIZE=400) ; ... displayed in a 400 x 400 window widget_control, tlb, /REALIZE widget_control, wDraw, GET_VALUE=winID wset, winID ; Finally, the PLOT call that fills the 10,000 x 400 canvas plot, x, sin(y), XTICKS=50, YTICKLEN=0.002 This widget program is particularly easy because a program does not have to implement an event handler, if all that is wanted is scrollbar functionality. If, however, Andrew, you really wanted to implement the functionality that captures keyboard events, like 'Page Up/Down' presses, then you have to get into a more complicated version of the above, which requires the following additional steps: 1. You would have to add an XMANAGER event listener call after the code block above. 2. You would have to add an event handler routine to your program. 3. You would have to implement your WIDGET_DRAW call above with the KEYBOARD_EVENTS=1 setting. 4. Your event handler would check the event structure's 'key' field for the value of 9 and 10 (the codes for Page Up and Page Down, respectively), perhaps 7 and 8 as well (Up Arrow and Down Arrow, resp.). When those values appeared, "WIDGET_CONTROL, GET_DRAW_VIEW=..." followed by "WIDGET_CONTROL, SET_DRAW_VIEW=..." could be executed to reposition the window view according to your own mapping of the keyboard buttons to number of pixels to be scrolled. Even these 4 steps above can probably be implemented in ~10 lines additional of code compared to the above, but a programmer might like to do some general study of IDL widget programming in IDL's 'Building IDL Applications' manual before he/she created this more complicated scroll window. James Jones
    You are not authorized to post a reply.