Plot problem [message #39989] |
Tue, 29 June 2004 04:02  |
Andreas Ernst
Messages: 14 Registered: July 2002
|
Junior Member |
|
|
Hi:
I am trying to plot an array, which contains values of
angular momentum against another array, which contains the
time ranging from 0 to 1000.
The problem is, that the curve I obtain is discontinuous
and intermitted at some points. So the line goes from
t=0 to t=50, then there is nothing between t=50 and t=100,
and at t=100, the line starts again.
I am using psym=-1 as an option of PLOT (or OPLOT), which
should connect all the data points.
Why is this not the case?
Thanks in advance. Andreas
|
|
|
Re: plot problem [message #61621 is a reply to message #39989] |
Fri, 25 July 2008 10:50   |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
On Jul 25, 7:44 pm, humanumbre...@gmail.com wrote:
> On Jul 25, 1:41 pm, Paul van Delst <Paul.vanDe...@noaa.gov> wrote:
>
>
>
>> Paul van Delst wrote:
>>> d.po...@gmail.com wrote:
>>>> Folks
>>>> I want to plot N set of x,y data in a one figure in a loop like this:
>
>>>> For I =0, N-1 do begin
>
>>>> …
>>>> Plot, x(i),y(i)
>>>> Endfor
>>>> Actually these points are lat-lon data and I want to see all in one
>>>> figure
>>>> But oplot doesn’t work there.
>
>>> Try "plots"
>
>> Or
>
>> plot, x, y, psym=4
>
>> No loop.
>
> Also, remember to use [ ] for indexing an array. It's a much safer
> technique for portability.
Paul
no it is not accept plots and also with psym=4
just the line change to point
this data are from shap file(*.shp) and i want
each time plot one entity but.....
Cheers
P.s.:yes i know but in my kaybord i have not that barkets
|
|
|
Re: plot problem [message #61622 is a reply to message #39989] |
Fri, 25 July 2008 10:44   |
humanumbrella
Messages: 52 Registered: June 2008
|
Member |
|
|
On Jul 25, 1:41 pm, Paul van Delst <Paul.vanDe...@noaa.gov> wrote:
> Paul van Delst wrote:
>> d.po...@gmail.com wrote:
>>> Folks
>>> I want to plot N set of x,y data in a one figure in a loop like this:
>
>>> For I =0, N-1 do begin
>
>>> …
>>> Plot, x(i),y(i)
>>> Endfor
>>> Actually these points are lat-lon data and I want to see all in one
>>> figure
>>> But oplot doesn’t work there.
>
>> Try "plots"
>
> Or
>
> plot, x, y, psym=4
>
> No loop.
Also, remember to use [ ] for indexing an array. It's a much safer
technique for portability.
|
|
|
|
|
Re: plot problem [message #61709 is a reply to message #39989] |
Fri, 25 July 2008 12:45   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
d.poreh@gmail.com writes:
> i mean for example:
> pro test
>
> for i=3D0,20 do begin
> data=3D[[transpose(findgen(i+10)),transpose(findgen(i+10))*0 .1]]
> print,data
>
> plot,data[0,*],data[1,*]
> endfor
> end
I know what you mean, but it doesn't work. Here is the example
you should be using:
Pro test
r = Replicate(1, 36)
a = Findgen(36) * 10
data = CV_COORD(FROM_POLAR=Transpose([[a],[r]]), $
/DEGREES, /TO_RECT)
Plot, [0,1], /NoData, XRANGE=[-1,1], YRANGE=[-1,1]
Plots, data[0,*], data[1,*], PSYM=-2
END
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: plot problem [message #61710 is a reply to message #39989] |
Fri, 25 July 2008 12:28   |
pgrigis
Messages: 436 Registered: September 2007
|
Senior Member |
|
|
Try
plot,x,y,/nodata
for i=0,n do plots,... (or oplot,...)
Ciao,
Paolo
d.po...@gmail.com wrote:
> On 25 Jul., 11:41, David Fanning <n...@dfanning.com> wrote:
>> d.po...@gmail.com writes:
>>> I want to plot N set of x,y data in a �one figure in a loop like this:
>>
>>> For I =3D0, N-1 do begin
>>
>>> =85
>>> Plot, x(i),y(i)
>>> Endfor
>>> Actually these points are lat-lon data and I want to see all in one
>>> figure
>>> But oplot doesn=92t work there.
>>
>> I *really* don't want to get involved in this discussion
>> in any way, shape, or form. But if you wanted to see how
>> to read and display a shape file in lat/lon coordinates,
>> you *could* read this article:
>>
>> � http://www.dfanning.com/map_tips/shapefile.html
>>
>> And you could have a look at DrawStates:
>>
>> � http://www.dfanning.com/programs/drawstates.pro
>>
>> I am not available for questions, though. :-)
>>
>> Cheers,
>>
>> David
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
> i mean for example:
> pro test
>
> for i=0,20 do begin
> data=[[transpose(findgen(i+10)),transpose(findgen(i+10))*0.1 ]]
> print,data
>
> plot,data[0,*],data[1,*]
> endfor
> end
>
>
> Cheers
> Dave
|
|
|
Re: plot problem [message #61711 is a reply to message #39989] |
Fri, 25 July 2008 11:59   |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
On 25 Jul., 11:41, David Fanning <n...@dfanning.com> wrote:
> d.po...@gmail.com writes:
>> I want to plot N set of x,y data in a one figure in a loop like this:
>
>> For I =3D0, N-1 do begin
>
>> =85
>> Plot, x(i),y(i)
>> Endfor
>> Actually these points are lat-lon data and I want to see all in one
>> figure
>> But oplot doesn=92t work there.
>
> I *really* don't want to get involved in this discussion
> in any way, shape, or form. But if you wanted to see how
> to read and display a shape file in lat/lon coordinates,
> you *could* read this article:
>
> http://www.dfanning.com/map_tips/shapefile.html
>
> And you could have a look at DrawStates:
>
> http://www.dfanning.com/programs/drawstates.pro
>
> I am not available for questions, though. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
i mean for example:
pro test
for i=0,20 do begin
data=[[transpose(findgen(i+10)),transpose(findgen(i+10))*0.1 ]]
print,data
plot,data[0,*],data[1,*]
endfor
end
Cheers
Dave
|
|
|
|
Re: plot problem [message #61717 is a reply to message #61621] |
Fri, 25 July 2008 11:26   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
d.poreh@gmail.com wrote:
> On Jul 25, 7:44 pm, humanumbre...@gmail.com wrote:
>> On Jul 25, 1:41 pm, Paul van Delst <Paul.vanDe...@noaa.gov> wrote:
>>
>>
>>
>>> Paul van Delst wrote:
>>>> d.po...@gmail.com wrote:
>>>> > Folks
>>>> > I want to plot N set of x,y data in a one figure in a loop like this:
>>>> > For I =0, N-1 do begin
>>>> > �
>>>> > Plot, x(i),y(i)
>>>> > Endfor
>>>> > Actually these points are lat-lon data and I want to see all in one
>>>> > figure
>>>> > But oplot doesn�t work there.
>>>> Try "plots"
>>> Or
>>> plot, x, y, psym=4
>>> No loop.
>> Also, remember to use [ ] for indexing an array. It's a much safer
>> technique for portability.
>
> Paul
> no it is not accept plots and also with psym=4
> just the line change to point
> this data are from shap file(*.shp) and i want
> each time plot one entity but.....
I'm sorry... but your reply doesn't make any sense.
You need to provide more information (preferably the output of various help commands), and
a short example of the code illustrating what you have tried.
cheers,
paulv
|
|
|
|
|
|
Re: plot problem [message #80961 is a reply to message #39989] |
Sat, 28 July 2012 09:44   |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
On Saturday, July 28, 2012 2:31:57 AM UTC-7, alx wrote:
> Le samedi 28 juillet 2012 07:10:16 UTC+2, dave poreh a écrit :
>
>> On Friday, July 27, 2012 4:22:34 PM UTC-7, alx wrote:
>
>>
>
>>> Le vendredi 27 juillet 2012 18:22:28 UTC+2, dave poreh a écrit :
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> Works perfect. Thanks, just i need to pass a text for each graph:
>
>>
>
>>>
>
>>
>
>>>> !null = text(1,1, 'speed=',$\pm$ num2str, /data, font_size=12)
>
>>
>
>>>
>
>>
>
>>>> that stands for *speed= 10+- 0.2* for instance on each graph. Can you help pls.
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> Cheers,
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> Dave
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Try:
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> IDL> pl = objarr(6)
>
>>
>
>>>
>
>>
>
>>> IDL> for i=0,5 do begin
>
>>
>
>>>
>
>>
>
>>> IDL> pl[i] = plot(/TEST, LAYOUT=[3,2,i+1], CURRENT=(i ne 0))
>
>>
>
>>>
>
>>
>
>>> IDL> !null = text(100, 0.8-0.05*i, 'text', /DATA, TARGET=pl[i])
>
>>
>
>>>
>
>>
>
>>> IDL> endfor
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Alain.
>
>>
>
>>
>
>>
>
>> Dear Alx
>
>>
>
>> It is not working for me! here is the code:
>
>>
>
>> pro GPS_text
>
>>
>
>> cd,'C:\Documents and Settings\Dave\Desktop'
>
>>
>
>> pathName="d:\p\"
>
>>
>
>> List = findfile(pathName+"*.dat")
>
>>
>
>> nosFiles=N_ELEMENTS(List)
>
>>
>
>> data = ptrarr(nosFiles)
>
>>
>
>> outfile = STRARR(nosFiles)
>
>>
>
>> p1=objarr(27)
>
>>
>
>> for i = 0, nosFiles - 1 do begin
>
>>
>
>> x=read_ascii(list[i],DATA_START=1)
>
>>
>
>> rootname = File_Basename(list[i], '.dat')
>
>>
>
>> data[i] = ptr_new(x)
>
>>
>
>> vert=(*data[i]).(0)
>
>>
>
>> p1[i]=plot(vert[0,*],vert[1,*],'ob', /SYM_FILLED, $
>
>>
>
>> SYM_SIZE=0.5,MARGIN=[0.1,0.2,0.0,0.05],layout=[3,9,i+1],/CUR RENT)
>
>>
>
>> fit=linfit(vert[0,*],vert[1,*],yfit=yfit)
>
>>
>
>>
>
>>
>
>> !null = text(100, 0.8-0.05*i, 'speed=', /DATA, font_size=12, TARGET=p1[i])
>
>>
>
>>
>
>>
>
>> p2= plot(vert[0,*],yfit , thick=2,color='red',xrange=[1998,2013],$
>
>>
>
>> /overplot, /SYM_FILLED, /undoc)
>
>>
>
>> print, fit, mean(vert[6,*])
>
>>
>
>>
>
>>
>
>> endfor
>
>>
>
>>
>
>>
>
>> end
>
>
>
> I cannot run your code to see what is not working, but I guess that the issue comes from using /OVERPLOT in the 'p2' statement. Indeed, the OVERPLOT keyword in NG does not work exactly like the oplot statement in DG: in particular, axis ranges and labeling are changed as needed.
>
> To ensure an exact overplotting in your case, I would suggest to modify the 'p2' statement as follows:
>
>
>
> p2 = plot(vert[0,*], yfit , thick=2, color='red', xrange=p1[i].xrange, $
>
> yrange=p1[i].yrange, /overplot, /SYM_FILLED, /undoc)
>
>
>
> and maybe add 'xrange=[1998,2013]' in the 'p1' statement.
>
>
>
> By the way, what means the '/undoc' keyword you are using in your plot statement ?
>
>
>
> Alain.
NO it is not working:-(
|
|
|
Re: plot problem [message #80963 is a reply to message #39989] |
Sat, 28 July 2012 02:31   |
lecacheux.alain
Messages: 325 Registered: January 2008
|
Senior Member |
|
|
Le samedi 28 juillet 2012 07:10:16 UTC+2, dave poreh a écrit :
> On Friday, July 27, 2012 4:22:34 PM UTC-7, alx wrote:
>
>> Le vendredi 27 juillet 2012 18:22:28 UTC+2, dave poreh a écrit :
>
>>
>
>>>
>
>>
>
>>> Works perfect. Thanks, just i need to pass a text for each graph:
>
>>
>
>>> !null = text(1,1, 'speed=',$\pm$ num2str, /data, font_size=12)
>
>>
>
>>> that stands for *speed= 10+- 0.2* for instance on each graph. Can you help pls.
>
>>
>
>>>
>
>>
>
>>> Cheers,
>
>>
>
>>>
>
>>
>
>>> Dave
>
>>
>
>>
>
>>
>
>> Try:
>
>>
>
>>
>
>>
>
>> IDL> pl = objarr(6)
>
>>
>
>> IDL> for i=0,5 do begin
>
>>
>
>> IDL> pl[i] = plot(/TEST, LAYOUT=[3,2,i+1], CURRENT=(i ne 0))
>
>>
>
>> IDL> !null = text(100, 0.8-0.05*i, 'text', /DATA, TARGET=pl[i])
>
>>
>
>> IDL> endfor
>
>>
>
>>
>
>>
>
>> Alain.
>
>
>
> Dear Alx
>
> It is not working for me! here is the code:
>
> pro GPS_text
>
> cd,'C:\Documents and Settings\Dave\Desktop'
>
> pathName="d:\p\"
>
> List = findfile(pathName+"*.dat")
>
> nosFiles=N_ELEMENTS(List)
>
> data = ptrarr(nosFiles)
>
> outfile = STRARR(nosFiles)
>
> p1=objarr(27)
>
> for i = 0, nosFiles - 1 do begin
>
> x=read_ascii(list[i],DATA_START=1)
>
> rootname = File_Basename(list[i], '.dat')
>
> data[i] = ptr_new(x)
>
> vert=(*data[i]).(0)
>
> p1[i]=plot(vert[0,*],vert[1,*],'ob', /SYM_FILLED, $
>
> SYM_SIZE=0.5,MARGIN=[0.1,0.2,0.0,0.05],layout=[3,9,i+1],/CUR RENT)
>
> fit=linfit(vert[0,*],vert[1,*],yfit=yfit)
>
>
>
> !null = text(100, 0.8-0.05*i, 'speed=', /DATA, font_size=12, TARGET=p1[i])
>
>
>
> p2= plot(vert[0,*],yfit , thick=2,color='red',xrange=[1998,2013],$
>
> /overplot, /SYM_FILLED, /undoc)
>
> print, fit, mean(vert[6,*])
>
>
>
> endfor
>
>
>
> end
I cannot run your code to see what is not working, but I guess that the issue comes from using /OVERPLOT in the 'p2' statement. Indeed, the OVERPLOT keyword in NG does not work exactly like the oplot statement in DG: in particular, axis ranges and labeling are changed as needed.
To ensure an exact overplotting in your case, I would suggest to modify the 'p2' statement as follows:
p2 = plot(vert[0,*], yfit , thick=2, color='red', xrange=p1[i].xrange, $
yrange=p1[i].yrange, /overplot, /SYM_FILLED, /undoc)
and maybe add 'xrange=[1998,2013]' in the 'p1' statement.
By the way, what means the '/undoc' keyword you are using in your plot statement ?
Alain.
|
|
|
Re: plot problem [message #80964 is a reply to message #39989] |
Fri, 27 July 2012 22:10   |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
On Friday, July 27, 2012 4:22:34 PM UTC-7, alx wrote:
> Le vendredi 27 juillet 2012 18:22:28 UTC+2, dave poreh a écrit :
>
>>
>
>> Works perfect. Thanks, just i need to pass a text for each graph:
>
>> !null = text(1,1, 'speed=',$\pm$ num2str, /data, font_size=12)
>
>> that stands for *speed= 10+- 0.2* for instance on each graph. Can you help pls.
>
>>
>
>> Cheers,
>
>>
>
>> Dave
>
>
>
> Try:
>
>
>
> IDL> pl = objarr(6)
>
> IDL> for i=0,5 do begin
>
> IDL> pl[i] = plot(/TEST, LAYOUT=[3,2,i+1], CURRENT=(i ne 0))
>
> IDL> !null = text(100, 0.8-0.05*i, 'text', /DATA, TARGET=pl[i])
>
> IDL> endfor
>
>
>
> Alain.
Dear Alx
It is not working for me! here is the code:
pro GPS_text
cd,'C:\Documents and Settings\Dave\Desktop'
pathName="d:\p\"
List = findfile(pathName+"*.dat")
nosFiles=N_ELEMENTS(List)
data = ptrarr(nosFiles)
outfile = STRARR(nosFiles)
p1=objarr(27)
for i = 0, nosFiles - 1 do begin
x=read_ascii(list[i],DATA_START=1)
rootname = File_Basename(list[i], '.dat')
data[i] = ptr_new(x)
vert=(*data[i]).(0)
p1[i]=plot(vert[0,*],vert[1,*],'ob', /SYM_FILLED, $
SYM_SIZE=0.5,MARGIN=[0.1,0.2,0.0,0.05],layout=[3,9,i+1],/CUR RENT)
fit=linfit(vert[0,*],vert[1,*],yfit=yfit)
!null = text(100, 0.8-0.05*i, 'speed=', /DATA, font_size=12, TARGET=p1[i])
p2= plot(vert[0,*],yfit , thick=2,color='red',xrange=[1998,2013],$
/overplot, /SYM_FILLED, /undoc)
print, fit, mean(vert[6,*])
endfor
end
|
|
|
Re: plot problem [message #80965 is a reply to message #39989] |
Fri, 27 July 2012 16:22   |
lecacheux.alain
Messages: 325 Registered: January 2008
|
Senior Member |
|
|
Le vendredi 27 juillet 2012 18:22:28 UTC+2, dave poreh a écrit :
>
> Works perfect. Thanks, just i need to pass a text for each graph:
> !null = text(1,1, 'speed=',$\pm$ num2str, /data, font_size=12)
> that stands for *speed= 10+- 0.2* for instance on each graph. Can you help pls.
>
> Cheers,
>
> Dave
Try:
IDL> pl = objarr(6)
IDL> for i=0,5 do begin
IDL> pl[i] = plot(/TEST, LAYOUT=[3,2,i+1], CURRENT=(i ne 0))
IDL> !null = text(100, 0.8-0.05*i, 'text', /DATA, TARGET=pl[i])
IDL> endfor
Alain.
|
|
|
Re: plot problem [message #80970 is a reply to message #39989] |
Fri, 27 July 2012 09:22   |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
On Friday, July 27, 2012 5:16:21 AM UTC-7, alx wrote:
> Le jeudi 26 juillet 2012 21:34:44 UTC+2, dave poreh a écrit :
>
>> Folks
>
>> hi,
>
>> I have a problem: i have produced a plot (http://imageshack.us/photo/my-images/545/gps2idl.png/) and i need to increase the height of each graph in the figure.
>
>> Can sb help please?
>
>> Cheers,
>
>> Dave
>
>
>
> NG functions are well suited for such a multiplot figure.
>
> For instance, with your example of an array of 9x3 y-functions of the variable x, by using CURRENT and LAYOUT keywords, you can simply write:
>
>
>
> IDL> for i=0,9*3-1 do pl = plot(x, y[*,i], LAYOUT=[3,9,i+1], CURRENT=(i ne 0))
>
>
>
> Here LAYOUT creates the multiplot, CURRENT forces same window to be reused except on the first time.
>
> Then, to manage particular spacing, labels, etc in each sub-plot, you can use any other keywords (MARGIN, AXIS_STYLE, etc...) by indexing them with some logical function of i.
>
> For instance, to suppress axes on subplots which are not lying on the boundaries, you could use AXIS_STYLE=2*(((i mod 3) eq 1) && (i ne 1) && (i ne 25)), in which 2 and 0 means "box-style" and "no axis", respectively.
>
> For details on those keywords, please refer to the IDL documentation.
>
>
>
> Alain.
Works perfect. Thanks, just i need to pass a text for each graph:
!null = text(1,1, 'speed=',$\pm$ num2str, /data, font_size=12)
that stands for *speed= 10+- 0.2* for instance on each graph. Can you help pls.
Cheers,
Dave
|
|
|
Re: plot problem [message #80973 is a reply to message #39989] |
Fri, 27 July 2012 05:16   |
lecacheux.alain
Messages: 325 Registered: January 2008
|
Senior Member |
|
|
Le jeudi 26 juillet 2012 21:34:44 UTC+2, dave poreh a écrit :
> Folks
> hi,
> I have a problem: i have produced a plot (http://imageshack.us/photo/my-images/545/gps2idl.png/) and i need to increase the height of each graph in the figure.
> Can sb help please?
> Cheers,
> Dave
NG functions are well suited for such a multiplot figure.
For instance, with your example of an array of 9x3 y-functions of the variable x, by using CURRENT and LAYOUT keywords, you can simply write:
IDL> for i=0,9*3-1 do pl = plot(x, y[*,i], LAYOUT=[3,9,i+1], CURRENT=(i ne 0))
Here LAYOUT creates the multiplot, CURRENT forces same window to be reused except on the first time.
Then, to manage particular spacing, labels, etc in each sub-plot, you can use any other keywords (MARGIN, AXIS_STYLE, etc...) by indexing them with some logical function of i.
For instance, to suppress axes on subplots which are not lying on the boundaries, you could use AXIS_STYLE=2*(((i mod 3) eq 1) && (i ne 1) && (i ne 25)), in which 2 and 0 means "box-style" and "no axis", respectively.
For details on those keywords, please refer to the IDL documentation.
Alain.
|
|
|
|
Re: Plot problem [message #93925 is a reply to message #39989] |
Sat, 26 November 2016 04:43  |
dg86
Messages: 118 Registered: September 2012
|
Senior Member |
|
|
On Saturday, November 26, 2016 at 6:59:03 AM UTC-5, dave poreh wrote:
> Folks,
> I have a problem on saving my image:
>
> p = plot(...)
> .
> .
> .
> p.save, 'fefe.eps',BORDER=500, resolution=300
>
> but in the image that i save i miss some texts that are out of my window. I mean for instance the y title that I am missing...
> Can someone please help me?
> Cheers,
> Dave
The BORDER=500 seems really big to me. Have you tried BORDER=1 to see if that
works?
Also, the SAVE method gives very inconsistent results for different file formats. The raster
formats, such as PNG, typically look most like the screen display, which usually is what
I want. Vector formats, including EPS, PDF and SVG, can deviate substantially,
including differences in font size, color, transparency, and layout. It might be worthwhile
saving your plot as a PNG image to see if it looks right in that format.
It's possible that IDL is simply messing up the bounding box on the EPS output. You
can fix that manually by editing fefe.eps with a text editor. There also are various utilities
that attempt to fix broken bounding boxes in eps files.
I hope that IDL's ability to create vector graphics continues to improve with the next release.
All the best,
David
|
|
|