Try the updated code below where the x and y axes are switched
it the call to plot and the PSYM=10 is done by dupplicating the x and y
values.
Also, the first plot was modified to not label the last x-axis value so that
it
does not overlap the first label of the second plot.
Don Lindler
lindler@rockit.gsfc.nasa.gov
pro test ;Combine a scatter + Y histogram plot
x = indgen(100) ;X axis
y = abs(randomn(seed,100)*10) ;Create scattered Y data
xdivide = 0.7 ;Scatter plot is 0.7 of X plot area, histogram plot is 0.3
plot,x,y,/nodata,xtick_get=v ;Set up plotting coordinates but don't plot
;Get left and right margins in normalized coordinates
margins = [min(!x.window)-min(!x.region), $
min(!y.window)-min(!y.region), $
max(!x.region)-max(!x.window), $
max(!y.region)-max(!y.window)]
;Get total plot size
ysize = 1. - margins[1] - margins[3]
xsize = 1. - margins[0] - margins[2]
;Set up plot position for scatter plot
pos = [0,0,xdivide*xsize,ysize] + $
[margins[0],margins[1],margins[0],margins[1]]
plot,x,y,psym=1,pos=pos,xtickname=[replicate('',n_elements(v )-1),' ']
;Now set up plot position for (rotated) histogram plot, flip X and Y values
Pos = [ xdivide*xsize,0,xsize,ysize] + $
[margins[0],margins[1],margins[0],margins[1]]
h = histogram(y,min=!Y.crange[0],max = !Y.crange[1]) ;Histogram of Y
values
n = !Y.crange[1] - !y.crange[0]
xx = !Y.crange[0] + indgen(n) ;Xrange for histogram
xx = [transpose(xx)-0.5,transpose(xx)+0.5]
yy = [transpose(h),transpose(h)]
plot,yy,xx,yrange = !y.crange,ystyle=1,ytickname=[' ',' ','
'],yticks=2,/noerase, $
pos = pos
return
end
"Wayne Landsman" <landsman@mpb.gsfc.nasa.gov> wrote in message
news:3CED0A80.950535C2@mpb.gsfc.nasa.gov...
>
> I want to create an X-Y scatter plot, and have an associated plot of the
> Y
> histogram values placed snug next to it. This means that the
> histogram plot needs to be flipped 90 degrees so that the (original)
> X-axis of
> the histogram is snug against the right Y axis of the scatter plot.
> My
> approach has been to use the /XYEXCH keyword of the T3D procedure to
> flip the X
> and Y axis. This seems to work O.K. but the plot annotation now looks
> correct
> only if viewed through a mirror (for !P.FONT=-1 or 1) or is not
> positioned
> correctly (for !P.FONT = 0). I suppose that I could suppress the
> annotation and then rewrite it myself without the T3D keyword present.
>
|