Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/hst/training/events/IDLTopics/SSD98IDL/IDL_plotting1.html
Дата изменения: Unknown
Дата индексирования: Sun Dec 23 19:37:43 2007
Кодировка:

Поисковые слова: п п п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п
Beginner's IDL - Line Plots

Beginner's IDL - Line Plots I




The objective of this chapter is to provide a more in-depth look at a specific topic in IDL. Here we will look at line plots. We will go through steps, such as changing linestyles and symbols, you can use to modify your line plots.





Plotting Coordinate Systems


IDL can use any one of the following three plotting coordinate systems.

Data The coordinate system established by your data when you use a Plot, Contour, or Surface command. This is the default coordinate system for most of the IDL graphics commands.
Device The physical coordiante system of the graphics device. It ranges from 0 to the number of addressable rows and columns on the graphics display. Device coordinates are usually thought of as pixels. This is the default for the TV and TVScl commands.
Normal The normalized coordinate system. It ranges from 0 to 1 in the plot window.


The type of coordinate system is usually specified using keywords to the various graphic display commands:

xyouts, x, y, 'Sin(s)', /normal
cursor, x, y, /device



Displaying Data as a Line Plot


To general a line plot, one would use the plot procedure. The plot procedure can take one or two arguments. IDL will try to create the best plot with the information at hand, and it will automatically scale the plotting ranges. For example:

IDL> num = findgen(40)*10
IDL> line=sin(num*!DtoR)
IDL> plot, line


IDL will generate a plot using the x indices as the independent variable index, and the values in x as the dependent values.

You can provide a second argument to the plot command.


IDL> plot, num, line



Customizing your plots


To customize your plots, you can use the keywords associated with the plot procedure (you can find more about the keywords from the online help browser). Here are a few things you can do:


For example, if you want to use a different symbol:

IDL> plot, num, line, psym = 1



Choosing a Line Style


You can choose a different line style by using the LineStyle keyword.

IDL> plot, num, line, linestyle = 1


The table below summarizes the different type of line styles.

Value

Line Style

0

Solid

1

Dotted

2

Dashed

3

Dash Dot

4

Dash Dot Dot

5

Long Dash


You can also change the line thickness by using the Thick keyword.

IDL> plot, num, line, linestyle=2, thick=3



Choosing a Plotting Symbol


You can choose a different plotting symbol by using the PSym keyword.

IDL> plot, num, line, psym=1


The table below summarizes the different type of symbols.

Value

Symbol

0

No Symbol. Points are connected with solid lines.

1

Plus sign

2

Asterisk

3

Period

4

Diamond

5

Triangle

6

Square

7

X

8

User defined (with the UserSym procedure)

9

Undefined

10

Data is ploted in histogram mode.

-Psym

Negative values connect symbols with lines.


Using a negative value for the psym keyword will connect your symbols with lines.

IDL> plot, num, line, psym=-1

This will connect the plus signs with lines.

Creating your own plotting symbols


You can use the UserSym procedure to create your own symbol. The symbol you created can be used by setting the psym keyword to 8. Here is an example that creates a circle. The following steps first generate the data points for the circle, and then the usersym procedure is called to create the circle symbol.

IDL> n = 17.0 ; the circle will be "created" with 17 data points (vertices)
IDL> theta = findgen(n)/(n-1.0)*360.0*!DtoR ;
IDL> x = 1.0*sin(theta)
IDL> y = 1.0*cos(theta)
IDL> usersym, x, y


So now you can use the circle symbol by:

IDL> plot, num, line, psym = 8



Finally, you can change the size of the symbol by using the SymSize keyword:

IDL> plot, num, line, psym = 8, symsize = 2.0



Annotating your plots


When you look at the online help, you will notice that there are many keywords associated with the plot command. The table below lists a selected few to illustrate what you can used to annotate your plots. You should try to experiment with the various keywords available for the plot procedure.

CharSize The overall character size for the annotation. The character sizes for the different axes are scaled from this value. The main title is scaled to 1.25 times this size. A CharSize of 1.0 is normal size.
IDL> plot, num, line, charsize=2.0, title='GHRS spectrum
[XYZ]CharSize The character sizes for the annotation on the individual axes. The value of this keyword is used to scale the value set by the keyword CharSize.
IDL> plot, num, line, charsize=2.0, xcharsize=0.8, xtitle='wavelength'
Title Places a title above the plot.
IDL> plot, num, line, title='GHRS spectrum'
[XYZ]Title The title for each individual axis.
IDL> plot, num, line, xtitle='wavelength'
SubTitle Place a subtitle underneath the X axis.
[XYZ]TickName A string array of up to 30 elements containing the labels for major tick marks.



Exercise


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.



Paul Lee
updated: 11/6/98