IDL change the ticks

来源:互联网 发布:中国式逗小孩 知乎 编辑:程序博客网 时间:2024/05/18 22:40

[XYZ]CHARSIZE


Accepted by: AXIS Procedure, CONTOUR Procedure, PLOT Procedure, SHADE_SURF Procedure, SURFACE Procedure. System variable equivalents: ![XYZ].CHARSIZE.

The size of the characters used to annotate the axis and its title when Hershey fonts are selected. This keyword does not apply when hardware (i.e. PostScript) fonts are selected. This field is a scale factor applied to the global scale factor set by !P.CHARSIZE or the keyword CHARSIZE.

TICKLEN


Accepted by: AXIS Procedure, CONTOUR Procedure, PLOT Procedure, SHADE_SURF Procedure, SURFACE Procedure. System variable equivalent: !P.TICKLEN.

Controls the length of the axis tick marks, expressed as a fraction of the window size. The default value is 0.02. TICKLEN of 1.0 produces a grid, while a negative TICKLEN makes tick marks that extend outside the window, rather than inwards. A value of -0.02 makes tick marks that extend away from the plot. Individual axis ticks can be controlled with the[XYZ]TICKLEN keyword.

For example, to produce outward-going tick marks of the normal length:

PLOT, X, Y, TICKLEN = -0.02

To provide a new default tick length, set !P.TICKLEN.

[XYZ]THICK


Accepted by: AXIS Procedure, CONTOUR Procedure, PLOT Procedure, SHADE_SURF Procedure, SURFACE Procedure. System variable equivalent: ![XYZ].THICK.

This keyword controls the thickness of the lines forming the xy, or z axes and their tick marks. A value of 1.0 is the default.

Back to Keywords List

[XYZ]TICK_GET


Accepted by: AXIS Procedure, CONTOUR Procedure, PLOT Procedure, SHADE_SURF Procedure, SURFACE Procedure.

A named variable in which to return the values of the tick marks for the designated axis. The result is a double precision floating-point array with the same number of elements as ticks.

For example, to retrieve in the variable V the values of the tick marks selected by IDL for the Y axis:

PLOT, X, Y, YTICK_GET = V

[XYZ]TICKINTERVAL


Accepted by: AXIS Procedure, CONTOUR Procedure, PLOT Procedure, SHADE_SURF Procedure, SURFACE Procedure.

variable equivalent: ![XYZ].TICKINTERVAL

Set this keyword to a scalar indicating the interval between major tick marks for the first axis level. The default value is computed according to the axis range ([XYZ]RANGE) and the number of major tick intervals ([XYZ]TICKS). This keyword takes precedence over [XYZ]TICKS.

For example, if TICKUNITS=[“Seconds”, “Hours”, “Days”], and XTICKINTERVAL=30, then the interval between major ticks for the first axis level will be 30 seconds.

Back to Keywords List

[XYZ]TICKLAYOUT


Accepted by: AXIS Procedure, CONTOUR Procedure, PLOT Procedure, SHADE_SURF Procedure, SURFACE Procedure. System variable equivalent: ![XYZ].TICKLAYOUT.

Set this keyword to a scalar that indicates the tick layout style to be used to draw each level of the axis.

Valid values include:

  • 0 = The axis line, major tick marks and tick labels are all included. Minor tick marks only appear on the first level of the axis. This is the default tick layout style.
  • 1 = Only the labels for the major tick marks are drawn. The axis line, major tick marks, and minor tick marks are omitted.
  • 2 = Each major tick interval is outlined by a box. The tick labels are positioned within that box (left-aligned). For the first axis level only, the major and minor tick marks will also be drawn.

Note: For all tick layout styles, at least one tick label will appear on each level of the axis (even if no major tick marks fall along the axis line). If there are no major tick marks, the single tick label will be centered along the axis.

Back to Keywords List

[XYZ]TICKLEN


Accepted by: AXIS Procedure, CONTOUR Procedure, PLOT Procedure, SHADE_SURF Procedure, SURFACE Procedure. System variable equivalent: ![XYZ].TICKLEN.

This keyword controls the lengths of tick marks (expressed in normal coordinates) for the individual axes. This keyword, if nonzero, overrides the global tick length specified in !P.TICKLEN, and/or the TICKLEN keyword parameter, which is expressed as a fraction of the window size in the tick mark’s direction.

Back to Keywords List

[XYZ]TICKNAME


Accepted by: AXIS Procedure, CONTOUR Procedure, PLOT Procedure, SHADE_SURF Procedure, SURFACE Procedure. System variable equivalent: ![XYZ].TICKNAME.

A string array of up to 30 elements that controls the annotation of each tick mark. If omitted or if a given string element contains an empty string, IDL labels the tick mark with its value. To suppress the tick labels, supply a string array of one-character long, blank strings, i.e., REPLICATE(' ', N). Empty strings force IDL to number the tick mark with its value.

Note: If there are n tick-mark intervals, there are n + 1 tick marks and labels.

[XYZ]TICKS


Accepted by: AXIS Procedure, CONTOUR Procedure, PLOT Procedure, SHADE_SURF Procedure, SURFACE Procedure. System variable equivalent: ![XYZ].TICKS.

The number of major tick intervals to draw for the axis. If this keyword is set to zero or omitted, IDL selects from three to six tick intervals. Setting this value to n, where n > 1, produces exactly n tick intervals, and n+1 tick marks. Setting this value equal to 1 suppresses major tick marks. (Set [XYZ]MINOR=1 to suppress minor tick marks.)

Back to Keywords List

[XYZ]TICKUNITS


Accepted by: AXIS Procedure, CONTOUR Procedure, PLOT Procedure, SHADE_SURF Procedure, SURFACE Procedure. System variable equivalent: ![XYZ].TICKUNITS.

Set this keyword to a string or a vector of strings indicating the units to be used for axis tick labeling. If a vector of strings is provided, the axis will be drawn in multiple levels, where each string represents one level in the specified units.

Note: When creating multiple-level axes, you may need to adjust the plot positioning using the POSITION or[XYZ]MARGIN keywords in order to ensure that axis labels and titles are visible in the plot window.

The order in which the strings appear in the vector determines the order in which the corresponding unit levels will be drawn. The first string corresponds to the first level (the level nearest to the primary axis line).

Valid unit strings include:

  • 'Numeric'
  • 'Years'
  • 'Months'
  • 'Days'
  • 'Hours'
  • 'Minutes'
  • 'Seconds'
  • 'Time' - Use this value to indicate that the tick values are time values; IDL will determine the appropriate time intervals and tick label formats based upon the range of values covered by the axis.
  • ''- Use the empty string to indicate that no tick units are being explicitly set. This implies that a single axis level will be drawn using the 'Numeric' unit. This is the default setting.

If any of the time units are utilized, the tick values are interpreted as Julian date/time values.

Note that the singular form of each of the time value strings is also acceptable (e.g, TICKUNITS='Day' is equivalent to TICKUNITS='Days').

Note: Julian values must be in the range -1095 to 1827933925, which corresponds to calendar dates 1 Jan 4716 B.C.E. and 31 Dec 5000000, respectively.

Back to Keywords List

[XYZ]TICKV


Accepted by: AXIS Procedure, CONTOUR Procedure, PLOT Procedure, SHADE_SURF Procedure, SURFACE Procedure. System variable equivalent: ![XYZ].TICKV.

The data values for each tick mark, an array of up to 60 elements. You can directly specify these values, producing graphs with arbitrary tick marks. If you do this, IDL scales the axis from the first tick value to the last unless you directly specify a range.

Note: To specify the number of ticks and their values exactly, set [XYZ]TICKS=N(where N > 1) and [XYZ]TICKV=Values, where Values has N+1 elements.

Back to Keywords List


[XYZ]TICKFORMAT


Accepted by: AXIS Procedure, CONTOUR Procedure, PLOT Procedure, SHADE_SURF Procedure, SURFACE Procedure. System variable equivalent: ![XYZ].TICKFORMAT.

Set this keyword to a string or a vector of strings. The string can be a format string or a string containing the name of a function that returns a string to be used to format the axis tick mark labels. If a vector is provided, each string corresponds to a level of the axis. The [XYZ]TICKUNITS keyword determines the number of levels for an axis.

Each string is one of the following:

A format code:

If the string begins with an open parenthesis, it is treated as a standard format string. See Format Codes for more information on format codes.

Example 1: Display the X axis tick values using a format of F6.2 (six characters, with 2 places after the decimal point):

PLOT, X, Y, XTICKFORMAT='(F6.2)'

Example 2: Display the Y tick values using the “dollars and cents” format $dddd.dd:

PLOT, X, Y, YTICKFORMAT='("$", F7.2)'

The string 'LABEL_DATE' :

Set [XYZ]TICKFORMAT to the string 'LABEL_DATE' to create axes with date labels. The formatting of the labels is specified by first calling LABEL_DATE with the DATE_FORMAT keyword.

Example: Use the LABEL_DATE function as the callback function to display the X tick values in a date/time format:

dummy = LABEL_DATE(DATE_FORMAT='%M %Z')
mytimes = TIMEGEN(12, UNITS='MONTHS', START=JULDAY(1,1,2000))
y = FINDGEN(12)
PLOT, mytimes, y, XTICKUNITS='Time', XTICKFORMAT='LABEL_DATE'

See the Examples section of LABEL_DATE for more extensive examples.

The name of a user-defined function:

If the string does not begin with an open parenthesis, it is interpreted as the name of a callback function to be used to generate tick mark labels. This function is defined with either three or four parameters, depending on whether [XYZ]TICKUNITS is specified:

If [XYZ]TICKUNITS is not specified, the callback function is called with three parameters, AxisIndex, and Value, where:

  • Axis is the axis number: 0 for X axis, 1 for Y axis, 2 for Z axis.
  • Index is the tick mark index (indices start at 0).
  • Value is the data value at the tick mark (a double-precision floating point value).

Note: Value is a double-precision floating-point value that represents the Julian date. The Julian date follows the astronomical convention, where Julian date 0.0d corresponds to 1 Jan 4713 B.C.E. at 12 pm.

If [XYZ]TICKUNITS is specified, the callback function is called with four parameters, AxisIndexValue, and Level, where:

  • AxisIndex, and Value are the same as described above.
  • Level is the index of the axis level for the current tick value to be labeled (level indices start at 0).

Example 1: Use a callback function to display the Y tick values as a percentage of a fixed value. Note that because we don’t specify [XYZ]TICKUNITS, we do not include the Level parameter in our function definition:

FUNCTION YTICKS, axis, index, value
   fixvalue = 389.0d
   pvalue = (value/fixvalue) * 100.0d
   RETURN, STRING(pvalue, FORMAT='(D5.2,"%")')
END
 
PRO use_callback
   Y = FINDGEN(10)
   PLOT, Y, YTICKFORMAT='YTICKS'
END

Example 2: Create a two-level X axis. Display the X tick values in a customized date/time format that shows the number of days open for business for each month on one level, and marks leap years with an asterisk on another level:

FUNCTION XTICKS, axis, index, value, level
 
   CASE level OF
     0: BEGIN ; months
          ; Number of days open for business in given month:
          CALDAT, value, month
          open = [18,19,23,20,22,22,19,10,20,21,22,14]
          nbdays = open[month]
          ; Return a string containing the month name plus
          ; the number of business days in parentheses:
          RETURN, STRING(value, nbdays, $
             FORMAT='(C(CMoA), "(", I2, ")")') 
       END
     1: BEGIN ; years
          ; Generate a string for the year.
          yrStr = STRING(value, FORMAT='(C(CYI))')
          ; Determine if a leap year.  If so, 
          ; append an asterisk to the string.
          CALDAT, value, mo, da, yr
          IF (yr MOD 4 EQ 0) THEN BEGIN
             IF (yr MOD 100 EQ 0) THEN $
                isLeap = (yr MOD 400) EQ 0 $
             ELSE $
                IsLeap = 1b
          ENDIF ELSE $
          isLeap = 0b
          IF (isLeap NE 0b) THEN $
             yrStr = yrStr + '*'
             RETURN, yrStr 
          END
     ENDCASE
 
END
 
PRO plot_sales
 
   myDates = TIMEGEN(12, UNITS='Months', START=JULDAY(1,1,2000))
   sales = [180,190,230,200,220,220,190,100,200,210,220,140]
   PLOT, myDates, sales, XTICKUNITS=['Months', 'Years'], $
      XTICKFORMAT='XTICKS', XTITLE = 'Date (* = Leap Year)', $
      YTITLE='Sales (units)', POSITION = [0.2, 0.2, 0.9, 0.9]
 
END


0 0
原创粉丝点击