Coord_transform in axes [message #89639] |
Mon, 03 November 2014 16:12  |
joellama
Messages: 8 Registered: July 2013
|
Junior Member |
|
|
I am trying to add an axis to an image but am having some difficulty.
My array is the shape: values[150, 50] representing 150 days and 50 latitude bins for each day.
I'm plotting the image using
im = image(values)
and the image appears as expected but I want to add a y axis to label the values of theta. Each of the 50 latitude bins is uniform in sin(theta) going from -1 to +1 but I want the axis to be in terms of theta going from -90 to +90 degrees.
Ive looked at the coord_transform function in axis and that can get me from (-1, 1) to (-90, 90) but the scaling is then wrong because the latitude values aren't uniform in theta but sin(theta).
I'm completely drawing a blank on how to do this. Any help would be greatly appreciated!
|
|
|
Re: Coord_transform in axes [message #89640 is a reply to message #89639] |
Mon, 03 November 2014 16:17   |
joellama
Messages: 8 Registered: July 2013
|
Junior Member |
|
|
Just to be slightly clearer,
I'm basically after a y-axis that has tick marks -90, 30, 0, 30, 90 that are all roughly equally spaced - sin(theta) space rather than in theta space where it would be -90, -45, 0, 45, 90.
|
|
|
Re: Coord_transform in axes [message #89655 is a reply to message #89640] |
Thu, 06 November 2014 09:52  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
This is one way to do it: You can make your plot, then change the location of the axis ticks to arbitrary locations, and change the tick labels to arbitrary values.
imdata=dist(150,50) ;make some mock data
x=dindgen(150) ;make the x coordinates
y=-1d0+2d0*dindgen(50)/49d0 ;make the y coordinates from -1 to 1
myimage=image(imdata,x,y,axis_style=1,position=[0.2,0.2,0.8, 0.8],aspect_ratio=40.) ;make the image
nyticks=11 ;number of ticks for the y axis
ygrid=-1d0+2d0*dindgen(nyticks)/(nyticks-1d0) ;make an array of y tick values
ylabels=string(asin(ygrid)*180d0/!dpi,format='(I)') ;make the labels for the y axis
myimage['axis1'].tickvalues=ygrid ;replace the tick locations
myimage['axis1'].tickname=ylabels ;replace the tick labels
myimage.ytitle='$\theta$'
naxis=axis('y',location='right',title='sin($\theta$)',tickva lues=ygrid) ;add a second axis with the sines of the angle
On Monday, November 3, 2014 10:17:03 PM UTC-2, Joe Llama wrote:
> Just to be slightly clearer,
>
> I'm basically after a y-axis that has tick marks -90, 30, 0, 30, 90 that are all roughly equally spaced - sin(theta) space rather than in theta space where it would be -90, -45, 0, 45, 90.
|
|
|