— example added by Felix —
There are many examples, where a color-coded map (or landscape) shows the results best, for example when showing the energy-dependence of the pulse profile of pulsar. All data depending on two parameters (in the example the count-rate depends on energy and on phase) can be displayed conveniently in this way. Another popular example is to show the χ² landscape as function of two fit-parameters on such a map instead of only showing the confidence contours.
First of all, we need a 2d array A[y,x]. Let's stick to the energy dependent pulse profiles and assume we have four proiles pp1, pp2, pp3, and pp4 with 64 phase bins each, i.e pp# = Double_Type. We could than produce A by writing
variable A = Double_Type[4,64] ; A[0,*] = pp1 ; A[1,*] = pp2 ; A[2,*] = pp3 ; A[3,*] = pp4 ;
The easiest way to plot a 2d array like that is to use
But this gives us only a black and white image of the array.
It's much nicer to use the S-lang “PNG” module, which allows to save the plot as a PNG file.
require("png") ; % not necessary if isisscripts have been loaded
First of all, we'd like to transfer our array to an image of RGB values. This can be achieved using a color map (the
png_get_colormap_names function returns the names of all available color maps):
variable a_pic = png_gray_to_rgb(A, "rainbow") ;
Writing out is easy, just give the filename and the new array
png_write_flipped("mymap.png", a_pic) ; % _flipped to get x and y axes right
So far, so good, but the
mymap.png is not really informative at the moment as it lacks the important information which parameters were plotted. This can be easily achieved by using the x-fig module.
First we need to creat a new
require("xfig") ; % not necessary if isisscripts have been loaded variable map = xfig_plot_new(11,11) ;
Define the coordinates
(xmin, xmax, ymin, ymax), assuming that pp1 starts at 5keV and pp4 ends at 100keV.
map.world(0, 1, 5, 100) ;
Load the PNG-file
map.xlabel("Pulse phase") ; map.ylabel("Energy [keV]") ;
Render all of that to an EPS file:
mymap.eps contains our colorful map with the axes-labeled correctly.
This example shows a very basic plot. It can quite easily extended, for example by plotting a scale next to it (for example SLxfig Plotting Examples, Example 6, click on the image to see the code). Or you could whish that the
y-dimension of each pulse profile should represent its width in energy space, then you could make a new array with a lot of more rows in
y direction, were you write in every row the same pulse profile between a given energy range. Or you could want to define your own colormap, this can be done with