Back Home Up Next


Exercices plotting


  1. Create the 100-element vector Z = 10*X - 0.1*X^2, where X contains the integers between 0 and 99.

  2. Type PLOT,X,Z.  Examine the plot, noting the abscissa, ordinate, and default scaling adopted. 

  3. Do the same for PLOT,X,2*Z.  Note the change.

  4. Type OPLOT,X,Z and note what happens

  5. Do the same for PLOT,X,Z^2

  6. Do the same for PLOT,Z^2,X

  7. Use the optional plotting parameters XRANGE and YRANGE with PLOT,X,Z^2 to enlarge various parts of the plot of the Z^2 function.

  8. Plot log_10(X) vs. Z and X vs. log_10(Z) using the built-in PLOT_OI and PLOT_IO commands.  (Note: you'll have to limit the X,Y scales using the RANGE parameters to avoid infinities and plot compression.  Keep the variable on the log axis greater than or equal to 1.0.)

  9. Label any of these plots, using the !P.TITLE, !X.TITLE, and !Y.TITLE system variable strings. All of the plots should have appeared in Window 0.  Try alternating successive plots between Window 0 and Window 1.[NOTE: The intrinsic IDL routines for manipulating windows are as follows:  To create a new window, use WINDOW,N.  To expose or hide an existing window, use WSHOW,N.  To make a given window "active"--- i.e. ready for I/O---use WSET,N.]

  10. Create the 1000-element vector x, where x contains the FLOATING-POINT conversion of integer values between -500 and +499.  Create Z = 10*X - 0.1*X^2 .

  11. Using PLOT,X,Z explore plotting features as in the previous exercise.  

  12. Type PLOT,Z.  How does the resulting plot differ from that for PLOT,X,Z?

  13. Create the 1000-element vector X, where x contains the INTEGER values between -500 and +499. Create Y = 10*X - 0.1*X^2.

  14. Type PLOT,X,Y.  Why does the Y function differ from Z?

  15. Now define X to contain the integers in the range 0 to 100.  Then compute Z = SIN(X)/X.  Is Z a floating point variable?

  16. Print the value of Z at X = 0.  If you weren't sure how IDL would respond there, how would you manually insert a value Z = 0 at X = 0?  Do so.  Confirm that the z vector is now defined everywhere.  

  17. Using the PSYM and LINESTYLE keywords, plot Z vs. X for integer values of X in the range 0 to 100: 
        with a solid line
        then with plus signs
        then with open triangles
        then with a dashed line

  18. Plot Z vs. X for the X range [0:10] with open triangles.  Then, using OPLOT, add a solid line overplot.

  19. You can achieve the same result with a single PLOT command for your choice of plotting symbol, K, by using PSYM=-Krather than PSYM=K.

  20. Calculate Z = SIN(X)/X at intervals of 0.01 for X in the range 0 to 10.

  21. Plot Z vs X.  

  22. Using the WHERE function, find all the locations where Z has an absolute value smaller than 0.05.  How many are there?  Print Z for all those locations (but only those locations) to your terminal. 

  23. Plot Z vs X using a solid line.  Now overplot open triangles at those points you found where Z has an absolute value smaller than 0.05. 




IDL courses C. Morisset 2004 IA/UNAM V 2.2

Back Home Up Next