comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: Missing fill colours in contour plot

Re: Missing fill colours in contour plot
type: item
description: On Tuesday, 15 January 2013 20:56:23 UTC, lj...@fsmail.net wrote: > I am trying to do a contour plot of a latitude-longitude array, but I keep getting gaps in my plot, as shown in the following image: http://www.physics.open.ac.uk/~lsteele/contour.png. I'm stumped as to the reason, as it's not as if it's missing contours at the very end ranges of the contour values - it's somewhere in between. Anyhow, I'm sure the knowledgable folks on here will know! > > > > I have defined a blue-white-red colour scheme and loaded it in with tvlct, but the problem occurs with other colour schemes too. I am calculating my contour levels and colours as follows (with ncont the number of contours I'm plotting): > > > > minv = floor(min(array)) > > maxv = ceil(max(array)) > > maxval = max([abs(array),abs(array)]) > > clevels = -maxval + findgen(ncont)/(ncont-1)*2*maxval > > ccol = floor(findgen(ncont)/(ncont-1)*250) > > > > I am then plotting my contour plot as: > > > > device, decomposed=0 > > bwr_colour, red_vec, grn_vec, blu_vec > > tvlct, red_vec, grn_vec, blu_vec > > contour, array, lon, lat, $ > > levels=clevels, c_colors=ccol, /fill, $ > > background=cgColor('white'), color=cgColor('black'), $ > > xrange=[-180,180], yrange=[-90,90], xstyle=1, ystyle=1, $ > > yticks=6, ytickv=[-90,-60,-30,0,30,60,90], $ > > xticks=6, xtickv=[-180,-120,-60,0,60,120,180], $ > > xtitle='Longitude', ytitle='Latitude', charsize=1.5, $ > > title=plotsym+' (all motions) / g m!u-1!n s!u-1!n' > > > > If anyone can offer any suggestions then I'll be very grateful, as it's bugging me now! > > > > Cheers, > > > > Liam Sorry - I made a mistake when typing the code to the newsgroup. The maxval statement actually reads: maxval = max([abs(minv),abs(maxv)])
creator: tortoisesaregreat
date: 2013-01-15T22:07:12-00:00

Re: Missing fill colours in contour plot
type: item
description: On Tuesday, January 15, 2013 1:56:23 PM UTC-7, lj...@fsmail.net wrote: > I am trying to do a contour plot of a latitude-longitude array, but I keep getting gaps in my plot, as shown in the following image: http://www.physics.open.ac.uk/~lsteele/contour.png. I'm stumped as to the reason, as it's not as if it's missing contours at the very end ranges of the contour values - it's somewhere in between. Anyhow, I'm sure the knowledgable folks on here will know! > > > > I have defined a blue-white-red colour scheme and loaded it in with tvlct, but the problem occurs with other colour schemes too. I am calculating my contour levels and colours as follows (with ncont the number of contours I'm plotting): > > > > minv = floor(min(array)) > > maxv = ceil(max(array)) > > maxval = max([abs(array),abs(array)]) > > clevels = -maxval + findgen(ncont)/(ncont-1)*2*maxval > > ccol = floor(findgen(ncont)/(ncont-1)*250) > > > > I am then plotting my contour plot as: > > > > device, decomposed=0 > > bwr_colour, red_vec, grn_vec, blu_vec > > tvlct, red_vec, grn_vec, blu_vec > > contour, array, lon, lat, $ > > levels=clevels, c_colors=ccol, /fill, $ > > background=cgColor('white'), color=cgColor('black'), $ > > xrange=[-180,180], yrange=[-90,90], xstyle=1, ystyle=1, $ > > yticks=6, ytickv=[-90,-60,-30,0,30,60,90], $ > > xticks=6, xtickv=[-180,-120,-60,0,60,120,180], $ > > xtitle='Longitude', ytitle='Latitude', charsize=1.5, $ > > title=plotsym+' (all motions) / g m!u-1!n s!u-1!n' > > > > If anyone can offer any suggestions then I'll be very grateful, as it's bugging me now! Just seeing "lon", "lat", and "contour" causes me to think that one of your problems is that you should be using the CELL_FILL keyword, rather than the FILL keyword. http://www.idlcoyote.com/color_tips/fill_colors.html If that doesn't work, I'd try cgCONTOUR. That routine will fill up the "normal" hole Contour creates. http://www.idlcoyote.com/tips/contour_hole.php Cheers, David
creator: DavidF[1]
date: 2013-01-15T22:14:04-00:00

Re: Missing fill colours in contour plot
type: item
description: On Tuesday, 15 January 2013 22:14:04 UTC, Coyote wrote: > On Tuesday, January 15, 2013 1:56:23 PM UTC-7, lj...@fsmail.net wrote: > >> I am trying to do a contour plot of a latitude-longitude array, but I keep getting gaps in my plot, as shown in the following image: http://www.physics.open.ac.uk/~lsteele/contour.png. I'm stumped as to the reason, as it's not as if it's missing contours at the very end ranges of the contour values - it's somewhere in between. Anyhow, I'm sure the knowledgable folks on here will know! > >> > >> > >> > >> I have defined a blue-white-red colour scheme and loaded it in with tvlct, but the problem occurs with other colour schemes too. I am calculating my contour levels and colours as follows (with ncont the number of contours I'm plotting): > >> > >> > >> > >> minv = floor(min(array)) > >> > >> maxv = ceil(max(array)) > >> > >> maxval = max([abs(array),abs(array)]) > >> > >> clevels = -maxval + findgen(ncont)/(ncont-1)*2*maxval > >> > >> ccol = floor(findgen(ncont)/(ncont-1)*250) > >> > >> > >> > >> I am then plotting my contour plot as: > >> > >> > >> > >> device, decomposed=0 > >> > >> bwr_colour, red_vec, grn_vec, blu_vec > >> > >> tvlct, red_vec, grn_vec, blu_vec > >> > >> contour, array, lon, lat, $ > >> > >> levels=clevels, c_colors=ccol, /fill, $ > >> > >> background=cgColor('white'), color=cgColor('black'), $ > >> > >> xrange=[-180,180], yrange=[-90,90], xstyle=1, ystyle=1, $ > >> > >> yticks=6, ytickv=[-90,-60,-30,0,30,60,90], $ > >> > >> xticks=6, xtickv=[-180,-120,-60,0,60,120,180], $ > >> > >> xtitle='Longitude', ytitle='Latitude', charsize=1.5, $ > >> > >> title=plotsym+' (all motions) / g m!u-1!n s!u-1!n' > >> > >> > >> > >> If anyone can offer any suggestions then I'll be very grateful, as it's bugging me now! > > > > Just seeing "lon", "lat", and "contour" causes me to think that one of your problems is that you should be using the CELL_FILL keyword, rather than the FILL keyword. > > > > http://www.idlcoyote.com/color_tips…
creator: tortoisesaregreat
date: 2013-01-16T00:11:50-00:00

Re: Missing fill colours in contour plot
type: item
description: On Wednesday, January 16, 2013 12:11:50 AM UTC, tortoise...@gmail.com wrote: > On Tuesday, 15 January 2013 22:14:04 UTC, Coyote wrote: > >> On Tuesday, January 15, 2013 1:56:23 PM UTC-7, lj...@fsmail.net wrote: > >> > >>> I am trying to do a contour plot of a latitude-longitude array, but I keep getting gaps in my plot, as shown in the following image: http://www.physics.open.ac.uk/~lsteele/contour.png. I'm stumped as to the reason, as it's not as if it's missing contours at the very end ranges of the contour values - it's somewhere in between. Anyhow, I'm sure the knowledgable folks on here will know! > >> > >>> > >> > >>> > >> > >>> > >> > >>> I have defined a blue-white-red colour scheme and loaded it in with tvlct, but the problem occurs with other colour schemes too. I am calculating my contour levels and colours as follows (with ncont the number of contours I'm plotting): > >> > >>> > >> > >>> > >> > >>> > >> > >>> minv = floor(min(array)) > >> > >>> > >> > >>> maxv = ceil(max(array)) > >> > >>> > >> > >>> maxval = max([abs(array),abs(array)]) > >> > >>> > >> > >>> clevels = -maxval + findgen(ncont)/(ncont-1)*2*maxval > >> > >>> > >> > >>> ccol = floor(findgen(ncont)/(ncont-1)*250) > >> > >>> > >> > >>> > >> > >>> > >> > >>> I am then plotting my contour plot as: > >> > >>> > >> > >>> > >> > >>> > >> > >>> device, decomposed=0 > >> > >>> > >> > >>> bwr_colour, red_vec, grn_vec, blu_vec > >> > >>> > >> > >>> tvlct, red_vec, grn_vec, blu_vec > >> > >>> > >> > >>> contour, array, lon, lat, $ > >> > >>> > >> > >>> levels=clevels, c_colors=ccol, /fill, $ > >> > >>> > >> > >>> background=cgColor('white'), color=cgColor('black'), $ > >> > >>> > >> > >>> xrange=[-180,180], yrange=[-90,90], xstyle=1, ystyle=1, $ > >> > >>> > >> > >>> yticks=6, ytickv=[-90,-60,-30,0,30,60,90], $ > >> > >>> > >> > >>> xticks=6, xtickv=[-180,-120,-60,0,60,120,180], $ > >> > >>> > >> > >>> xtitle='Longitude', ytitle='Latitude', charsize=1.5, $ > >> > >>> > >> > >>> title=plotsym+' (all mot…
creator: Sir Loin Steak
date: 2013-01-16T09:51:49-00:00

Re: Missing fill colours in contour plot
type: item
description: On Wednesday, January 16, 2013 9:51:49 AM UTC, lj...@fsmail.net wrote: > On Wednesday, January 16, 2013 12:11:50 AM UTC, tortoise...@gmail.com wrote: > >> On Tuesday, 15 January 2013 22:14:04 UTC, Coyote wrote: > >> > >>> On Tuesday, January 15, 2013 1:56:23 PM UTC-7, lj...@fsmail.net wrote: > >> > >>> > >> > >>>> I am trying to do a contour plot of a latitude-longitude array, but I keep getting gaps in my plot, as shown in the following image: http://www.physics.open.ac.uk/~lsteele/contour.png. I'm stumped as to the reason, as it's not as if it's missing contours at the very end ranges of the contour values - it's somewhere in between. Anyhow, I'm sure the knowledgable folks on here will know! > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> I have defined a blue-white-red colour scheme and loaded it in with tvlct, but the problem occurs with other colour schemes too. I am calculating my contour levels and colours as follows (with ncont the number of contours I'm plotting): > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> minv = floor(min(array)) > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> maxv = ceil(max(array)) > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> maxval = max([abs(array),abs(array)]) > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> clevels = -maxval + findgen(ncont)/(ncont-1)*2*maxval > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> ccol = floor(findgen(ncont)/(ncont-1)*250) > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> I am then plotting my contour plot as: > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> device, decomposed=0 > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> bwr_colour, red_vec, grn_vec, blu_vec > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> tvlct, red_vec, grn_vec, blu_vec > >> > >>> > >> > >>>> > >> > >>> > >> > >>>> contour, array, lon, lat, $ > >> > >>> > >> > >>>> > >…
creator: Sir Loin Steak
date: 2013-01-16T10:28:19-00:00

Re: Missing fill colours in contour plot
type: item
description: ljs15@fsmail.net writes: > Hmm, well neither cell_fill nor cgcontour fix the problem. I'll have to have another fiddle and see what I can do, but it seems like it should work! If neither of those work, then I think the next thing to look for are unfounded assumptions in the input to the Contour routine. :-) Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thue. ("Perhaps thou speakest truth.")
creator: David Fanning
date: 2013-01-16T14:15:50-00:00

Re: Missing fill colours in contour plot
type: item
description: ljs15@fsmail.net writes: > Right, I've just done some more checking, and when I specify the colour values to range from 0-255 it works, but when I set them to range from 0-250 it doesn't. The two plots are shown at http://www.physics.open.ac.uk/~lsteele/contour2. > > In the two plots shown, the left is done using ccol=floor(findgen(ncont)/(ncont-1)*255) and the right is done using ccol=floor(findgen(ncont)/(ncont-1)*250), with ncont=30. So, the only change is going from 255 to 250, with the contours being correct at 255. > > Does anyone know why this would be causing a problem? I think you have a fairly odd way of selecting colors and contours, which is causing a mismatch between the contours, the data, and the colors. What happens if you set the contours and colors up this way: minv = Floor(min(array)) maxv = Ceil(max(array)) ncont = 30 clevels = Findgen(ncont) * ((maxv - minv) / ncont) + minv LoadCT, 25, NCOLORS=ncont, BOTTOM=1 ccol= Bindgen(ncont)+1B Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thue. ("Perhaps thou speakest truth.")
creator: David Fanning
date: 2013-01-16T14:34:52-00:00

Re: Missing fill colours in contour plot
type: item
description: On Wednesday, January 16, 2013 2:34:52 PM UTC, David Fanning wrote: > ljs15@fsmail.net writes: > > > >> Right, I've just done some more checking, and when I specify the colour values to range from 0-255 it works, but when I set them to range from 0-250 it doesn't. The two plots are shown at http://www.physics.open.ac.uk/~lsteele/contour2. > >> > >> In the two plots shown, the left is done using ccol=floor(findgen(ncont)/(ncont-1)*255) and the right is done using ccol=floor(findgen(ncont)/(ncont-1)*250), with ncont=30. So, the only change is going from 255 to 250, with the contours being correct at 255. > >> > >> Does anyone know why this would be causing a problem? > > > > I think you have a fairly odd way of selecting colors and contours, > > which is causing a mismatch between the contours, the data, and the > > colors. What happens if you set the contours and colors up this way: > > > > minv = Floor(min(array)) > > maxv = Ceil(max(array)) > > ncont = 30 > > clevels = Findgen(ncont) * ((maxv - minv) / ncont) + minv > > LoadCT, 25, NCOLORS=ncont, BOTTOM=1 > > ccol= Bindgen(ncont)+1B > > > > Cheers, > > > > David > > -- > > David Fanning, Ph.D. > > Fanning Software Consulting, Inc. > > Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ > > Sepore ma de ni thue. ("Perhaps thou speakest truth.") Hi David. The reason for specifying the contours is that the data range from positive to negative values, and I'm using a blue-white-red colour scale to plot (+ve is red, -ve is blue). In order to make sure white represents 0, I need to set the contour levels to span the maximum range. So if the data had minv = -20 and maxv = +50, I want the contours to range from -50 to +50. There may be a better way of doing it than what I'm doing though!
creator: Sir Loin Steak
date: 2013-01-16T14:47:01-00:00

Re: Missing fill colours in contour plot
type: item
description: ljs15@fsmail.net writes: > The reason for specifying the contours is that the data range from positive to negative values, and I'm using a blue-white-red colour scale to plot (+ve is red, -ve is blue). > > In order to make sure white represents 0, I need to set the contour levels to span the maximum range. So if the data had minv = -20 and maxv = +50, I want the contours to range from -50 to +50. > > There may be a better way of doing it than what I'm doing though! Well, I would do it like this: maxval = Max(Abs(array)) clevels = Scale_Vector(Findgen(ncont), Floor(-maxval), Ceil(maxval)) cgLoadCT, 22, /Brewer, /Reverse, NCOLORS=ncont, BOTTOM=1 ccols = Bindgen(ncont)+1B Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thue. ("Perhaps thou speakest truth.")
creator: David Fanning
date: 2013-01-16T14:57:39-00:00

Re: Missing fill colours in contour plot
type: item
description: On Wednesday, January 16, 2013 2:57:39 PM UTC, David Fanning wrote: > ljs15@fsmail.net writes: > > > >> The reason for specifying the contours is that the data range from positive to negative values, and I'm using a blue-white-red colour scale to plot (+ve is red, -ve is blue). > >> > >> In order to make sure white represents 0, I need to set the contour levels to span the maximum range. So if the data had minv = -20 and maxv = +50, I want the contours to range from -50 to +50. > >> > >> There may be a better way of doing it than what I'm doing though! > > > > Well, I would do it like this: > > > > > > maxval = Max(Abs(array)) > > clevels = Scale_Vector(Findgen(ncont), Floor(-maxval), Ceil(maxval)) > > cgLoadCT, 22, /Brewer, /Reverse, NCOLORS=ncont, BOTTOM=1 > > ccols = Bindgen(ncont)+1B > > > > Cheers, > > > > David > > > > -- > > David Fanning, Ph.D. > > Fanning Software Consulting, Inc. > > Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ > > Sepore ma de ni thue. ("Perhaps thou speakest truth.") Much neater than my hackneyed version. I'll revert to this method - thanks David. P.S. I never realised there were Brewer colour tables. Whenever I've wanted blue-white-red I've always created my own. This will make my life much easier!
creator: Sir Loin Steak
date: 2013-01-17T17:34:06-00:00

Re: Missing fill colours in contour plot
type: item
description: ljs15@fsmail.net writes: > P.S. I never realised there were Brewer colour tables. Whenever I've wanted blue-white-red I've always created my own. This will make my life much easier! Yes, so will a lot of other Coyote Library routines. ;-) Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.idlcoyote.com/ Sepore ma de ni thue. ("Perhaps thou speakest truth.")
creator: David Fanning
date: 2013-01-17T18:02:58-00:00

Re: Missing fill colours in contour plot
type: item
description: On 1/17/13 10:34 am, ljs15@fsmail.net wrote: > P.S. I never realised there were Brewer colour tables. Whenever I've > wanted blue-white-red I've always created my own. This will make my > life much easier! Brewer color tables were added to IDL in 8.2.1. Mike -- Michael Galloy www.michaelgalloy.com Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com) Research Mathematician Tech-X Corporation
creator: Michael Galloy
date: 2013-01-20T18:25:01-00:00