On Monday, 16 May 2016 13:07:13 UTC+1, steve...@metoffice.gov.uk wrote:
> On Monday, 16 May 2016 12:26:47 UTC+1, Steve wrote:
>> Hi
>>
>> I am having trouble labeling a time axis on an image. Here is some test code
>>
>> ;create a randomn image for testing
>> data = RANDOMU(seed,1800,401)
>> img = BYTSCL(data)
>>
>> ;data values that I would like to use for labeling the axes
>> xval = FINDGEN(1800)/(60.*60.*24.) + JULDAY(11,24,2014,11,15,00)
>> yval = FINDGEN(401)-200.
>>
>> ;plot the image and label the axes
>> im = IMAGE(img, RGB_TABLE=0,MARGIN=0.2)
>> yax = AXIS('Y', LOCATION=[0,0], TICKDIR=1, MINOR=0, COORD_TRANSFORM=[yval[0],1])
>> xax = AXIS('X', LOCATION=[0,0], TICKDIR=1, MINOR=0, TICKFORMAT='(C(CHI2.2, ":", CMI2.2))', COORD_TRANSFORM=[xval[0],1.])
>>
>> I am using COORD_TRANSFORM in the call to AXIS to try and convert the pixel number of the image to what I would like to display. In the example above this works for the yaxis which simply changes the axis data values. For the xaxis I am also trying to display it in a time format as HH:MM but all of the axes labels display as 00:00.
>>
>> Any idea how I can label the xaxis correctly?
>>
>> Thanks
>>
>> Steve
>
> Just spotted an error in my test code. The xaxis should be
>
> xax = AXIS('X', LOCATION=[0,0], TICKDIR=1, MINOR=0, TICKFORMAT='(C(CHI2.2, ":", CMI2.2))', COORD_TRANSFORM=[xval[0],1./(60.*60.*24.)])
>
> This does put what look to be about the correct times but they all overlay each other on the axis. Something is not quite right!
>
> Steve
OK so a little more playing around with this and I guess the problem may be due to COORD_TRANSFORM not using double precision, such that when it displays the time values on the xaxis they end up overlaying each other. Perhaps someone can confirm.
So a big fudge to get this to work is to change
xval = FINDGEN(1800)/(60.*60.*24.) + JULDAY(11,24,-4712,11,15,00)
such that the data values put into COORD_TRANSFORM are not as large. Clearly I wouldn't be able to display the time axis with the year labeled in this case.
If anyone has a better solution to the above that would be great.
Steve
|