I was trying to look into Therion's source, to work out how it decides the highest and lowest parts of the displayed map, and how it determines the colours to use. I can see it uses thset_color in thparse.cxx, which in turn uses thHSV2RGB. That is a HSV to RGB converter, that returns RGB values in the 0-1 range. thset_color intentionally reduces the hue range to stop it from looping back towards red. All very easy to understand. This is called by thexpmap.cxx, and the work seems to happen in the thexpmap::export_pdf_set_colors function. But what I don't understand is why in the loop there, this line of code seems to ask only for 6 colours: if (addleg && (maxz > minz) && (this->layout->color_crit == TT_LAYOUT_CCRIT_ALTITUDE)) { The PDF shows 7 colours (which I have documented in the wiki page about lookups). How come it manages to get 7, when the code seems to ask for 6? If I plug the numbers in that I would get from that 6-loop, I do not get the colours that I would expect. If I plug in the numbers for a 7-loop, then I get the right colours. What is happening? Is it actually some other code somewhere else that does the legend altitudes - thlookup maybe?