# coyote: CGZPLOT__DEFINE

- coyote/Graphics
- [Source code]

Description

      This program creates a "zoomable" line plot in an interactive, resizable window. The user
      can zoom into or out of the plot. Once a plot is zoomed, the user can then pan the plot
      in both the X and Y directions. See the operating instructions for how to interact
      with the line plot.
      Operating Instructions--
      Use the LEFT mouse button to zoom the plot and the RIGHT mouse button to pan the plot.
      If you click and drag inside the plot axes, you will create a rubber band box. Select the
      portion of data you wish to zoom into. The zoom will occur in both the X and Y directions.
      If you wish to zoom the plot all the way back out, simply click and release the LEFT mouse
      button inside the plot axes without moving the mouse.
      Once you are zoomed into a plot, you can adjust the zoom by clicking the LEFT mouse button
      outside the plot axes. If you click the mouse below the plot, you will cause the X axis to
      zoom out of the plot by the zoomFactor amount (normally 5% of the current range of the axis).
      If you wish to zoom the X axis into the plot, simply click above in the region of the window
      above the plot. Click below the plot to zoom out, above the plot to zoom in. Similarly, you
      can adjust the zoom on the Y axis. Clicking to the left of the plot zooms the Y axis out,
      while clicking to the right of the plot zooms the Y axis in.
      If you are zoomed into the plot, you can pan to different locations in the plot by using
      the RIGHT mouse button. Hold and drag the RIGHT mouse button inside the plot axes. The
      entire plot will pan in both the X and Y directions.
      File output requires that ImageMagick and GhostScript be installed on your machine. Note
      that exact axis scaling is always in effect.
      This program object is accessed through the cgZPlot procedure, as in the examples below.

Categories

      Graphics

Examples

      Use as you would use the cgPlot command::
         cgZPlot, cgDemoData(1)
         cgZPlot, cgDemoData(1), Aspect=1.0
         cgZPlot, cgDemoData(1), Color='olive', AxisColor='red', Thick=2
         cgZPlot, cgDemoData(1), Color='blue', SymColor='red', PSym=-16
       Example using error bars::
         data = Congrid(cgDemoData(1), 15)
         seed = -5L
         time = cgScaleVector(Findgen(N_Elements(data)), 1, 9)
         high_yerror = RandomU(seed, N_Elements(data)) * 5 > 0.5
         low_yerror = RandomU(seed, N_Elements(data)) * 4 > 0.25
         high_xerror = RandomU(seed, N_Elements(data)) * 0.75 > 0.1
         low_xerror = RandomU(seed, N_Elements(data))  * 0.75 > 0.1
         xtitle = 'Time'
         ytitle = 'Signal Strength'
         title = 'Error Bar Plot'
         position = [0.125, 0.125, 0.9, 0.925]
         thick = (!D.Name EQ 'PS') ? 3 : 1
         cgZPlot, time, data, Color='red5', PSym=-16, $
             SymSize=1.0, Thick=thick, Title=title, XTitle=xtitle, YTitle=ytitle, $
             Position=position, YStyle=1, $
             ERR_XLow=low_xerror, ERR_XHigh=high_xerror, ERR_CLIP=1, $
             ERR_YLow=low_yerror, ERR_YHigh=high_yerror, ERR_Color='blu5'

Author

      FANNING SOFTWARE CONSULTING::
         David W. Fanning
         1645 Sheely Drive
         Fort Collins, CO 80526 USA
         Phone: 970-221-0438
         E-mail: david@idlcoyote.com
         Coyote's Guide to IDL Programming: http://www.idlcoyote.com

Copyright

      Copyright (c) 2012, Fanning Software Consulting, Inc.

History

      Change History::
         Written 16 May 2012, by David W. Fanning.
         Added UNDO capability arbitrarily set to 50 items. 17 May 2012. DWF.
         Added a REDO capability and the ability to adjust the Y range (via a button) so that
            you can see the actual data Y range of all the data in the X range of a particular
            view of the data. 21 May 2012. DWF.
         Added a PARENT keyword and changed the algorithm slightly so that this
            interactive widget functionality can be incorporated into your own
            widget programs. 21 may 2012. DWF.
         Added compile options idl2 to all modules. Fixed a typo for REDO button. 14 June 2012. DWF.
         Separated the object code from the driver code for easier inheritance. 14 June 2012. DWF.
         Removed the POLAR keyword, which can't be used in a zoom plot. 15 June 2012. DWF.
         Added a persistent output save directory.  30 June 2012. DWF.
         Added an ERASE method to erase the current display. 10 July 2012. DWF.
         Added a LABEL keyword to add a label instead of a title to a plot. 13 July 2012. DWF.
         Added the ability to include overplot objects in the zoom window. 17 July 2012. DWF.
         Added a Destroy method and now remove widget GUI in CLEANUP method. 2 Oct 2012. DWF.
         I had the GetProperty and SetProperty keyword inheritance mechanism screwed up. Sorted
            now. 13 March 2013. DWF.
         Added the ability to display error bars on the zoomable plot. 30 Sep 2014. DWF.
         Added a SYMCOLOR keyword to the zoomable plot. 30 Sep 2014. DWF.
      s is the initialization method of the cgZPlot object. In general, any keyword appropriate
       the cgPlot command can be used with this program.

Params

      class: out, optional, type=struct
          The class definition object. Often helpful for obtaining fields of the object structure.

Keywords

      aspect: in, optional, type=float, default=none
         Set this keyword to a floating point ratio that represents the aspect ratio
         (ysize/xsize) of the resulting plot. The plot position may change as a result
         of setting this keyword. Note that `Aspect` cannot be used when plotting with
         !P.MULTI.
      dep: in, optional, type=any
         The dependent data to plot.
      draw: in, optional, type=boolean, default=0
         Set this keyword if you would like to immediately draw the plot after properties are set.
      err_clip: in, optional, type=boolean, default=0
         Set this keyword to cause error bars to be clipped to the borders of the plot.
         The default is to draw error bars, even if outside the plot.
      err_color: in, optional, type=varies
         The color error bars should be drawn in. The default is to use the `Color` keyword.
      err_thick:, in, optional, type=integer
         The thickness of the line for drawing the error bars. By default, !P.Thick.
      err_width: in, optional, type=float
         The width of the end lines on error bars in normalized coordinates. By default, the
         width is one percent of the width of the axes length in the appropriate dimension.
      err_xhigh: in, optional
          he high error values that should be added to the independent or X data values.
      err_xlow: in, optional
         The low error values that should be subtracted from the independent or X data values.
      err_yhigh: in, optional
         The high error values that should be added to the dependent or Y data values.
      err_ylow: in, optional
         The low error values that should be subtracted from the dependent or Y data values.
      indep: in, optional, type=any
         The independent data to plot.
      label: in, optional, type=string
         A label is similar to a plot title, but it is aligned to the left edge
         of the plot and is written in hardware fonts. Use of the label keyword
         will suppress the plot title.
      legends: in, optional, type=object
         A single cgLegendItem object, or an array of cgLegendItem objects that will be
         drawn on the plot as a legend.
      max_value: in, optional, type=float
         Set this keyword to the maximum value to plot. Any values greater than this
         value are treated as missing.
      min_value: in, optional, type=float
         Set this keyword to the minimu value to plot. Any values smaller than this
         value are treated as missing.
      oplots: in, optional, type=object
         A single cgOverPlot object, or an array of cgOverPlot objects that will be
         overplot on the axes set up by the original data.
      symcolor: in, optional, type=string/integer, default='black'
         If this keyword is a string, the name of the symbol color. By default, 'black'.
         Otherwise, the keyword is assumed to be a color index into the current color table.
      xlog: in, optional, type=boolean, default=0
         Set this keyword to use a logarithmic X axis
      ylog: in, optional, type=boolean, default=0
         Set this keyword to use a logarithmic Y axis
      ynozero: in, optional, type=boolean, default=0
         Set this keyword to use allow the Y axis to start at a value other than zero.
      zoomfactor: in, optional, type=float
         Set this keyword to a number between 0.01 and 0.25. This affects the amount
         of zooming when the X axis and Y axis are zoomed with the LEFT mouse button.
         The default value is 0.05 or five percent of the current axis range on each
         end of the axis, resulting in a 10 percent change in the axis length.
      _extra: in, optional, type=any
         Any keyword appropriate for the IDL Plot or Coyote Graphic cgPlot command is
         allowed in the program.
      s event handler method destroys the widget program.