Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.stsci.edu/hst/training/events/IDLTopics/SSD98IDL/IDL_plotting2.html
Дата изменения: Unknown Дата индексирования: Sun Dec 23 19:37:45 2007 Кодировка: Поисковые слова: п п п п п п п |
In IDL, you can specify the color of the various plot components. The available color
depends on the color table you are currently using. There is a procedure, xloadct,
that would allow you to interactively load and display the available color table
in IDL. Below is an example on how you can change the color of your plot as well
as the background.
IDL> loadct, 5
IDL> plot, num, line, color = 45, background = 200
This will draw the plot in blue on a yellow background. The numerical range for the
color is from 0 to 255.
If you want to plot the line with a different color, you will need to do the following
steps.
IDL> plot, num, line, color=45, background = 200, /nodata
IDL> oplot, num, line, color = 120
You can further customize your plot by using the [xyz]style keywords which
affects the frame of the plot. For example, if you would like to suppress the x axis:
IDL> plot, num, line, xstyle=4
Or if you would like to suppress the y axis:
IDL> plot, num, line, ystyle=4
Below summarizes the available changes:
Value |
Axis Property Affected |
1 |
Force exact axis range. |
2 |
Extend axis range. |
4 |
Suppress entire axis. |
8 |
Suppress box style axis. (Draw only one axis) |
16 |
Inhibit setting the Y axis starting value to 0. (Y axis only) |
IDL> plot, num, line, xstyle = 9, xrange = [0, 360]
The next section will talk about how to limit the range of the axes. Other keywords
you can explore include: TickLen, [XYZ]TickLen, [XYZ]GridStyle, [XYZ]Ticks, [XYZ]Minor.
One of the nice (or not so nice) features of IDL is that it automatically create
a plot using data ranges that suppositely give aesthetically pleasing axis annotations.
Furthermore, it by default will override a user's input range if IDL determines that
the range does not fall within it's sense of the range of aesthetically pleasing
axis annotation. To make IDL plots with your range, you will need to use the above
[xyz]style keyword as well as the xrange keyword.
IDL> plot, num, line, xstyle = 1, xrange=[0, 360]
Also, you can plot out average values of the data using the nsum keyword. For example,
to average every 5 data points and plot those average values:
IDL> plot, xdata, ydata, nsum = 5
You can change to a logarithmic axis scale by using the [XYZ]Log keywords.
To turn on the keyword, add a / in front of the keyword. For example, if you want
to set the x axis:
IDL> x = findgen(100)
IDL> theta = x/5
IDL> plot, x, theta, xrange=[0.1, 100], /xlog
To plot the data with the Y axis set, type:
IDL> plot, x, theta, yrange[0.01,100], /ylog
To set both:
IDL> plot, x, theta, xrange=[0.1,100],yrange=[0.01,100], /xlog, /ylog
If you have multiple data sets and you would like to plot them all together, use
the oplot command:
IDL> plot, data_set1
IDL> oplot, data_set2, linestyle = 1
IDL> oplot, data_set3, linestyle = 2
Note: The first dataset you plot establishes the data range for all subsequent overplots.
You will have to make sure that the range of the first plot can cover the other datasets.
The exact range can be set using the xstyle and xrange keywords.
Other commands to try out: axis
Besides the title labels, you can add text strings to the plot at locations specify
by you. The xyouts procedure takes the input text strings and place it at
the x and y coordinates specified. To use xyouts, a plot must already exist
in the display window. For example:
IDL> plot, num, line
IDL> xyouts, 0.5, 200, 'Sine Curve'
Notice that you specify the X and Y location with data coordinates. By default, the
xyouts procedure uses the data coordinate system, but the device and normal coordinate
systems can be specified with appropriate keywords: /normal, /device.
Fonts
The xyouts procedure can also take advantage of software or vector fonts.
IDL comes supplied with a number of fonts. To use those fonts, put the fonts number
(listed in the table below) right before
the string of characters (inside the quote) you want to set. For example:
IDL> xyouts, 0.5, 200, '!11Sine Curve!X'
Number | Font Type | Number | Font Type |
!3 | Simplex Roman | !12 | Simplex Script |
!4 | Simplex Greek | !13 | Complex Script |
!5 | Duplex Roman | !14 | Gothic Italian |
!6 | Complex Roman | !15 | Gothic German |
!7 | Complex Greek | !16 | Cyrillic |
!8 | Complex Italian | !17 | Triplex Roman |
!9 | Math Font | !18 | Triplex Italian |
!10 | Special Characters | !20 | Miscellaneous |
!11 | Gothic English | !X | Revert to entry font |
Notice that we have specified the font type to be Gothic English by placing !11 in
front of the text string. The !X at the end of the string tells IDL that you would
like to switch back to the font type before the change. If you do not specify this,
all subsequent strings will be set with Gothic English characters.
Positioning Commands
The positioning and other font-manipulation commands are listed in the table below.
For complete reference, see page 43 of the IDL Reference guide. Below is an example
of writing a superscript.
IDL> xyouts, 0.5, 200, '!6E=mc!E2'
On the plot, the string will reads: E = mc2
Positioning Commands | Action |
!A | Shift above the division line. |
!B | Shift below the divisionline. |
!C | "Carriage return," begins a new line of text. Shift back to the starting position and down one line. |
!D | Shift down to the first level subscript and decrease the character size by a factor of 0.62. |
!E | Shift up to the exponent level and decrease the character size by a factor of 0.44. |
!I | Shift down to the index level and decrease the character size by a factor of 0.44. |
!L | Shift down to the second level subscript. Decrease the character size by a factor of 0.62. |
!N | Shift back to the normal level and original character size. |
!R | Restore position. The current position is set from the top of the saved position stack. |
!S | Save position. The currente position is saved on the top of the saved positions stack. |
!U | Shift to upper subscript level. Decrease the character size by a factor of 0.62. |
!X | Return to the entry font. |
!! | Display the ! symbol. |
To plot points or draw lines on a plot, one would use the PlotS procedure.
To draw a line with the PlotS procedure, simply provide it with vectors containing
the endpoints of the line. Here is an example in which it is used to draw a baseline
at y = 0:
IDL> plot, x, y, xstyle=1, xrange=[0,6]
IDL> plots, [0,6],[0,0], linestyle = 2
The plots procedure can also be used to place marker symbols at various locations.
For example, the following commands will draw a diamond shape (psym = 4) at the (x,y)
locations (1,1), (2,3), (3,4).
IDL> xx = [1,2,3]
IDL> yy = [1,3,4]
IDL> plots, xx, yy, psym = 4
If you wanted to connect the symbols with lines, use a negative value for the psym
keyword like before.
IDL> plots, xx, yy, psym = -4
Using what you have learned here, try to modify your plot of the GHRS spectrum. Also,
try to incorporate the changes into your plotting program.