astromonerd
astromonerd

Reputation: 937

How do I use multiple variables in an IDL plot title?

In IDL I would like to create a title for my plot using variable names and their values computed during the program. For a single variable, TITLE = var_name.

How would I list two variable names and their values within the TITLE keyword? Something like TITLE = "var1:" var1 "var2:" var2 doesn't work, and no combinations of quotes and commas seems to work.

Thank you.

Upvotes: 1

Views: 886

Answers (1)

mgalloy
mgalloy

Reputation: 2386

The TITLE keyword expects a string. If you have several names and values you have to decide how to make them into a string. For example, you could do this with a structure in a simple manner:

IDL> s = { var1: 0., var2: 3. }
IDL> t = ''
IDL> for i = 0, n_tags(s) - 1L do $
IDL>   t += string((tag_names(s))[i], s.(i), format='(A, ": ", F, " ")')
IDL> print, t
VAR1:       0.0000000 VAR2:       3.0000000

You can, of course, get as fancy with the format codes as you want.

Upvotes: 1

Related Questions