comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Simple issue with PLOTS?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Simple issue with PLOTS? [message #81672] Tue, 09 October 2012 11:41
Rob.Dimeo is currently offline  Rob.Dimeo
Messages: 21
Registered: September 2007
Junior Member
Bill,

Well....not too much futzing...

I used your approach and it works nicely now. Thanks,

Rob

pro test_grid_win
; Test program
xsize = (ysize = 500)
device,decomposed = 0 & loadct,0,/silent
nx = 10 & board = byte(round(randomu(s,nx,nx)))

window,0,xsize = xsize,ysize = ysize
dx = 1./float(nx)
erase,255B
plot, [0,1],[0,1], /nodata, xgrid=1, ygrid=1,background = 255B,xmargin
= [1,1],ymargin = [1,1],/noerase
c1 = convert_coord(0.,0.,/data,/to_device)
c2 = convert_coord(1.,1.,/data,/to_device)
nxsize = c2[0] - c1[0]
nysize = c2[1] - c1[1]

tv,byte(255*congrid(board,nxsize,nysize)),c1[0],c1[1],xsize =
nxsize,ysize = nysize,/device
for j = 0,nx do oplot,[j*dx,j*dx],[0.0,1.0], color = 0B
for j = 0,nx do oplot,[0.0,1.0],[j*dx,j*dx], color = 0B
end
Re: Simple issue with PLOTS? [message #81673 is a reply to message #81672] Tue, 09 October 2012 11:24 Go to previous message
Rob.Dimeo is currently offline  Rob.Dimeo
Messages: 21
Registered: September 2007
Junior Member
Bill,

Thanks for your reply. I am using TV to put an image in the window
prior to drawing the grid. To use the method you propose I will need
to scale the image into the plot axes. Rather than use TV as I've been
doing, I think that I'll have to futz around a bit. I have been trying
to use TV rather than some other image display wrapper because the
images I'm displaying are not static. I want the display part of my
program to work as fast as possible. In any case, what I'm doing might
not be as straightforward as I had originally hoped. Thanks for your
help.

Rob

On Oct 9, 1:53 pm, Bill Gallery <wogall...@comcast.net> wrote:
> On Tuesday, October 9, 2012 11:08:03 AM UTC-6, Rob wrote:
>> Hi,
>
>> It's been quite a while since I've programmed in IDL but I have a
>
>> problem with something very basic. I am drawing a grid using the PLOTS
>
>> command but the final lines are not being drawn (i.e. the top and
>
>> rightmost lines). I might use a hack to get it to look right (i.e.
>
>> enlarge the window by a few pixels) but it's not a very elegant
>
>> solution. Below I list a simple procedure that shows the issue. You
>
>> should see a window pop up with most of the grid except for lines
>
>> along the top and along the right. Any help on my pedestrian
>
>> problem? :o)
>
>> Thanks,
>
>> Rob
>
>> pro test_grid_win
>
>> ; Test program that writes out a PNG file that captures the screen
>
>> with
>
>> ; a grid drawn on it.
>
>> xsize = (ysize = 500)
>
>> device,decomposed = 0 & loadct,0,/silent
>
>> nx = 10
>
>> window,0,xsize = xsize,ysize = ysize
>
>> dx = 1./float(nx)
>
>> erase,255B
>
>> for j = 0,nx do plots,[j*dx,j*dx],[0.0,1.0],/normal,color = 0B
>
>> for j = 0,nx do plots,[0.0,1.0],[j*dx,j*dx],/normal,color = 0B
>
>> ;filename = 'e:\test.png'
>
>> ;WRITE_PNG, filename, TVRD(/TRUE)
>
>> end
>
> Rob,
>
> Try this version of your program.  The comments explain what you need to change and why.
>
> Cheers,
> Bill Gallery
>
> pro test_grid_win
> ; Test program that writes out a PNG file that captures the screen with
> ; a grid drawn on it.
> xsize = (ysize = 500)
> device,decomposed = 0 & loadct,0,/silent
> nx = 10
> window,0,xsize = xsize,ysize = ysize
> dx = 1./float(nx)
> ;;erase,255B
> !p.BACKGROUND=255b  ;set the default background color
> !p.COLOR=0  ;set the default color of plot axes, points, lines, ...
>
> ;;plots places points on an already specified grid
> ;;You need to first use plot (no s) to set up the scale of the plot and
> ;;to draw the axes
> ;;the x and y data set the scale of the plot to x=[0,1], y=[0,1]
> ;;xgrid=1 and ygrid=1 ensure that the x and y axes are exacty as specified and
> ;;not expanded
> ;;/nodata prevents data from actually being plotted
> plot, [0,1],[0,1], /nodata, xgrid=1, ygrid=1
>
> ;;use oplot to place the data on the existing plot (plots will also work)
> ;;/normal says that the data is in 'normal' coordinates which vary from
> ;;[0,0] at the lower left of the screen to [1,1] to the upper right:
> ;;this is not what you want. You want to draw on the existing data scale
> ;;which has been created with the plot command.
> ;;The color of the data has already been specified with !p.color
> for j = 0,nx do oplot,[j*dx,j*dx],[0.0,1.0]   ;;,/normal,color = 0B
> for j = 0,nx do oplot,[0.0,1.0],[j*dx,j*dx]   ;;,/normal,color = 0B
> ;filename = 'e:\test.png'
> ;WRITE_PNG, filename, TVRD(/TRUE)
> end
Re: Simple issue with PLOTS? [message #81674 is a reply to message #81673] Tue, 09 October 2012 10:53 Go to previous message
BillG is currently offline  BillG
Messages: 6
Registered: March 2007
Junior Member
On Tuesday, October 9, 2012 11:08:03 AM UTC-6, Rob wrote:
> Hi,
>
> It's been quite a while since I've programmed in IDL but I have a
>
> problem with something very basic. I am drawing a grid using the PLOTS
>
> command but the final lines are not being drawn (i.e. the top and
>
> rightmost lines). I might use a hack to get it to look right (i.e.
>
> enlarge the window by a few pixels) but it's not a very elegant
>
> solution. Below I list a simple procedure that shows the issue. You
>
> should see a window pop up with most of the grid except for lines
>
> along the top and along the right. Any help on my pedestrian
>
> problem? :o)
>
> Thanks,
>
> Rob
>
>
>
> pro test_grid_win
>
> ; Test program that writes out a PNG file that captures the screen
>
> with
>
> ; a grid drawn on it.
>
> xsize = (ysize = 500)
>
> device,decomposed = 0 & loadct,0,/silent
>
> nx = 10
>
> window,0,xsize = xsize,ysize = ysize
>
> dx = 1./float(nx)
>
> erase,255B
>
> for j = 0,nx do plots,[j*dx,j*dx],[0.0,1.0],/normal,color = 0B
>
> for j = 0,nx do plots,[0.0,1.0],[j*dx,j*dx],/normal,color = 0B
>
> ;filename = 'e:\test.png'
>
> ;WRITE_PNG, filename, TVRD(/TRUE)
>
> end

Rob,

Try this version of your program. The comments explain what you need to change and why.

Cheers,
Bill Gallery

pro test_grid_win
; Test program that writes out a PNG file that captures the screen with
; a grid drawn on it.
xsize = (ysize = 500)
device,decomposed = 0 & loadct,0,/silent
nx = 10
window,0,xsize = xsize,ysize = ysize
dx = 1./float(nx)
;;erase,255B
!p.BACKGROUND=255b ;set the default background color
!p.COLOR=0 ;set the default color of plot axes, points, lines, ...

;;plots places points on an already specified grid
;;You need to first use plot (no s) to set up the scale of the plot and
;;to draw the axes
;;the x and y data set the scale of the plot to x=[0,1], y=[0,1]
;;xgrid=1 and ygrid=1 ensure that the x and y axes are exacty as specified and
;;not expanded
;;/nodata prevents data from actually being plotted
plot, [0,1],[0,1], /nodata, xgrid=1, ygrid=1

;;use oplot to place the data on the existing plot (plots will also work)
;;/normal says that the data is in 'normal' coordinates which vary from
;;[0,0] at the lower left of the screen to [1,1] to the upper right:
;;this is not what you want. You want to draw on the existing data scale
;;which has been created with the plot command.
;;The color of the data has already been specified with !p.color
for j = 0,nx do oplot,[j*dx,j*dx],[0.0,1.0] ;;,/normal,color = 0B
for j = 0,nx do oplot,[0.0,1.0],[j*dx,j*dx] ;;,/normal,color = 0B
;filename = 'e:\test.png'
;WRITE_PNG, filename, TVRD(/TRUE)
end
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Simple issue with PLOTS?
Next Topic: using a custom build script (IDL 8.2)?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:38:28 PDT 2025

Total time taken to generate the page: 0.00458 seconds