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

Home » Public Forums » archive » Re: Missing fill colours in contour plot
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: Missing fill colours in contour plot [message #82776] Thu, 17 January 2013 10:02 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
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.")
Re: Missing fill colours in contour plot [message #82779 is a reply to message #82776] Thu, 17 January 2013 09:34 Go to previous messageGo to next message
Sir Loin Steak is currently offline  Sir Loin Steak
Messages: 42
Registered: January 2012
Member
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!
Re: Missing fill colours in contour plot [message #82801 is a reply to message #82779] Wed, 16 January 2013 06:57 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
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.")
Re: Missing fill colours in contour plot [message #82802 is a reply to message #82801] Wed, 16 January 2013 06:47 Go to previous messageGo to next message
Sir Loin Steak is currently offline  Sir Loin Steak
Messages: 42
Registered: January 2012
Member
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!
Re: Missing fill colours in contour plot [message #82803 is a reply to message #82802] Wed, 16 January 2013 06:34 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
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.")
Re: Missing fill colours in contour plot [message #82804 is a reply to message #82803] Wed, 16 January 2013 06:15 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
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.")
Re: Missing fill colours in contour plot [message #82809 is a reply to message #82804] Wed, 16 January 2013 02:28 Go to previous messageGo to next message
Sir Loin Steak is currently offline  Sir Loin Steak
Messages: 42
Registered: January 2012
Member
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, $
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> 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
>
>>
>
>>
>
>>
>
>> Thanks David - I'll give both a try tomorrow and see what happens!
>
>
>
> 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!

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?

Cheers,

Liam
Re: Missing fill colours in contour plot [message #82812 is a reply to message #82809] Wed, 16 January 2013 01:51 Go to previous messageGo to next message
Sir Loin Steak is currently offline  Sir Loin Steak
Messages: 42
Registered: January 2012
Member
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 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
>
>
>
> Thanks David - I'll give both a try tomorrow and see what happens!

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!
Re: Missing fill colours in contour plot [message #82817 is a reply to message #82812] Tue, 15 January 2013 16:11 Go to previous messageGo to next message
tortoisesaregreat is currently offline  tortoisesaregreat
Messages: 2
Registered: January 2013
Junior Member
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/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

Thanks David - I'll give both a try tomorrow and see what happens!
Re: Missing fill colours in contour plot [message #82826 is a reply to message #82817] Tue, 15 January 2013 14:14 Go to previous messageGo to next message
DavidF[1] is currently offline  DavidF[1]
Messages: 94
Registered: April 2012
Member
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
Re: Missing fill colours in contour plot [message #82827 is a reply to message #82826] Tue, 15 January 2013 14:07 Go to previous messageGo to next message
tortoisesaregreat is currently offline  tortoisesaregreat
Messages: 2
Registered: January 2013
Junior Member
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)])
Re: Missing fill colours in contour plot [message #82893 is a reply to message #82779] Sun, 20 January 2013 10:25 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: CgWindow and multiple plots
Next Topic: Matrices

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

Current Time: Wed Oct 08 15:12:04 PDT 2025

Total time taken to generate the page: 0.00569 seconds