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

Home » Public Forums » archive » Re: how to draw contour with continue color?
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: how to draw contour with continue color? [message #63625] Mon, 17 November 2008 04:46
xqinshan is currently offline  xqinshan
Messages: 21
Registered: November 2008
Junior Member
On 11月16日, 下午11时51分, David Fanning <n...@dfanning.com> wrote:
> xqinshan writes:
>> Thanks David. That work well for screen (set_plot,'win'), but for ps
>> (set_plot,'ps'),
>> device,decomposed=3D1
>> dosnot work. There is a white line in the image and colorbar. I hope
>> pictures of ps form can be the same as on screen. How to do that?
>
> Here is a version of the program that works on the display
> and in PostScript. In the future, if you want something
> in PostScript just say so, or write an e-mail to ITTVIS
> asking them to PLEASE get to work on updating the PostScript
> device. That way, I can jump through the necessary hoops
> from the beginning.
>
> data = Dist(300)
> step = (Max(data) - Min(data)) / 16.
> levels = Indgen(16) * step + Min(data)
> IF (!D.Flags AND 256) NE 0 THEN BEGIN
> Device, Decomposed=1, Get_Decomposed=theState
> Erase, Color=FSC_Color('ivory')
> ENDIF
> CTLoad, 4, /Brewer, NCOLORS=255
> black = FSC_Color('black', 255)
> pos = [0.15, 0.15, 0.9, 0.75]
> TVImage, BytScl(data, TOP=254), POSITION=pos
> Contour, data, /NOERASE, POSITION=pos, XSTYLE=1, YSTYLE=1, $
> LEVELS=levels, COLOR=black, C_LABEL=Replicate(1, 16)
> Colorbar, NCOLORS=255, RANGE=[Min(data), Max(data)], DIVISIONS=4, $
> POSITION=[0.15, 0.8, 0.9, 0.85], /TOP, COLOR=black
> IF (!D.Flags AND 256) NE 0 THEN Device, Decomposed=theState
> 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.")

Great! Many thanks!
Re: how to draw contour with continue color? [message #63651 is a reply to message #63625] Sun, 16 November 2008 07:51 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
xqinshan writes:

> Thanks David. That work well for screen (set_plot,'win'), but for ps
> (set_plot,'ps'),
> device,decomposed=3D1
> dosnot work. There is a white line in the image and colorbar. I hope
> pictures of ps form can be the same as on screen. How to do that?

Here is a version of the program that works on the display
and in PostScript. In the future, if you want something
in PostScript just say so, or write an e-mail to ITTVIS
asking them to PLEASE get to work on updating the PostScript
device. That way, I can jump through the necessary hoops
from the beginning.

data = Dist(300)
step = (Max(data) - Min(data)) / 16.
levels = Indgen(16) * step + Min(data)
IF (!D.Flags AND 256) NE 0 THEN BEGIN
Device, Decomposed=1, Get_Decomposed=theState
Erase, Color=FSC_Color('ivory')
ENDIF
CTLoad, 4, /Brewer, NCOLORS=255
black = FSC_Color('black', 255)
pos = [0.15, 0.15, 0.9, 0.75]
TVImage, BytScl(data, TOP=254), POSITION=pos
Contour, data, /NOERASE, POSITION=pos, XSTYLE=1, YSTYLE=1, $
LEVELS=levels, COLOR=black, C_LABEL=Replicate(1, 16)
Colorbar, NCOLORS=255, RANGE=[Min(data), Max(data)], DIVISIONS=4, $
POSITION=[0.15, 0.8, 0.9, 0.85], /TOP, COLOR=black
IF (!D.Flags AND 256) NE 0 THEN Device, Decomposed=theState
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: how to draw contour with continue color? [message #63652 is a reply to message #63651] Sun, 16 November 2008 07:35 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
xqinshan writes:

> The result is there is a black line between 106 to 159 on the
> colorbar. I donot know why.

Well, the rule with 8-bit devices is "load the colors
before you use them". The black color in your color
bar is coming from the previous drawing of the contour
lines. Repeat the CTLOAD command just before you
draw your COLORBAR. (And, although this won't case
any problems now, change the COLOR keyword on the
Colobar command to ANNOTATECOLOR.

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: how to draw contour with continue color? [message #63653 is a reply to message #63652] Sun, 16 November 2008 07:12 Go to previous message
xqinshan is currently offline  xqinshan
Messages: 21
Registered: November 2008
Junior Member
On 11月16日, 下午10时02分, David Fanning <n...@dfanning.com> wrote:
> xqinshan writes:
>> Thanks David. That work well for screen (set_plot,'win'), but for ps
>> (set_plot,'ps'),
>> device,decomposed=3D1
>> dosnot work. There is a white line in the image and colorbar. I hope
>> pictures of ps form can be the same as on screen. How to do that?
>
> Take the DEVICE and ERASE commands out. Should work fine then.
>
> 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.")

This is the program:
set_plot,'ps'
device,filename='f:\image.ps',bits=8,/color

data = Dist(300)
step = (Max(data) - Min(data)) / 16.
levels = Indgen(16) * step + Min(data)
;Device, Decomposed=1
CTLoad, 14, /Brewer
pos = [0.15, 0.15, 0.9, 0.75]
;Erase, Color=FSC_Color('ivory')
TVImage, BytScl(data), POSITION=pos
Contour, data, /NOERASE, POSITION=pos, XSTYLE=1, YSTYLE=1, $
LEVELS=levels, COLOR=FSC_Color('black'), $
C_LABEL=Replicate(1, 16)
Colorbar, NCOLORS=256, RANGE=[Min(data), Max(data)], DIVISIONS=4,
$
POSITION=[0.15, 0.8, 0.9, 0.85], /TOP, COLOR=FSC_Color
('black')

device,/close
end

The result is there is a black line between 106 to 159 on the
colorbar. I donot know why.

Best
Xqinshan
Re: how to draw contour with continue color? [message #63655 is a reply to message #63653] Sun, 16 November 2008 06:02 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
xqinshan writes:

> Thanks David. That work well for screen (set_plot,'win'), but for ps
> (set_plot,'ps'),
> device,decomposed=3D1
> dosnot work. There is a white line in the image and colorbar. I hope
> pictures of ps form can be the same as on screen. How to do that?

Take the DEVICE and ERASE commands out. Should work fine then.

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: how to draw contour with continue color? [message #63656 is a reply to message #63655] Sun, 16 November 2008 05:34 Go to previous message
xqinshan is currently offline  xqinshan
Messages: 21
Registered: November 2008
Junior Member
On 11月16日, 下午4时57分, xqinshan <xqins...@tom.com> wrote:
> On 11月16日, 下午12时13分, David Fanning <n...@dfanning.com> wrote:
>
>
>
>
>
>> xqinshan writes:
>>> Hi, I use "contour...nlevels=..../fill" to get contour plot. The color
>>> variation is seperated. Although if I set nlevels=50 or more it looks
>>> better, but the contour color is not continuous. When I donot set
>>> nleves for "colorbar", the color of colorbar is continuous.But how can
>>> I do for contour?
>
>> You want an image, not a filled contour plot.
>
>> data = Dist(300)
>> step = (Max(data) - Min(data)) / 16.
>> levels = Indgen(16) * step + Min(data)
>> Device, Decomposed=1
>> CTLoad, 4, /Brewer
>> pos = [0.15, 0.15, 0.9, 0.75]
>> Erase, Color=FSC_Color('ivory')
>> TVImage, BytScl(data), POSITION=pos
>> Contour, data, /NOERASE, POSITION=pos, XSTYLE=1, YSTYLE=1, $
>> LEVELS=levels, COLOR=FSC_Color('black'), $
>> C_LABEL=Replicate(1, 16)
>> Colorbar, NCOLORS=256, RANGE=[Min(data), Max(data)], DIVISIONS=4, $
>> POSITION=[0.15, 0.8, 0.9, 0.85], /TOP, COLOR=FSC_Color('black')
>
>> 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.")
>
> Thanks very much!-

Thanks David. That work well for screen (set_plot,'win'), but for ps
(set_plot,'ps'),
device,decomposed=1
dosnot work. There is a white line in the image and colorbar. I hope
pictures of ps form can be the same as on screen. How to do that?

Best
Xqinshan
Re: how to draw contour with continue color? [message #63657 is a reply to message #63656] Sun, 16 November 2008 00:57 Go to previous message
xqinshan is currently offline  xqinshan
Messages: 21
Registered: November 2008
Junior Member
On 11月16日, 下午12时13分, David Fanning <n...@dfanning.com> wrote:
> xqinshan writes:
>> Hi, I use "contour...nlevels=..../fill" to get contour plot. The color
>> variation is seperated. Although if I set nlevels=50 or more it looks
>> better, but the contour color is not continuous. When I donot set
>> nleves for "colorbar", the color of colorbar is continuous.But how can
>> I do for contour?
>
> You want an image, not a filled contour plot.
>
> data = Dist(300)
> step = (Max(data) - Min(data)) / 16.
> levels = Indgen(16) * step + Min(data)
> Device, Decomposed=1
> CTLoad, 4, /Brewer
> pos = [0.15, 0.15, 0.9, 0.75]
> Erase, Color=FSC_Color('ivory')
> TVImage, BytScl(data), POSITION=pos
> Contour, data, /NOERASE, POSITION=pos, XSTYLE=1, YSTYLE=1, $
> LEVELS=levels, COLOR=FSC_Color('black'), $
> C_LABEL=Replicate(1, 16)
> Colorbar, NCOLORS=256, RANGE=[Min(data), Max(data)], DIVISIONS=4, $
> POSITION=[0.15, 0.8, 0.9, 0.85], /TOP, COLOR=FSC_Color('black')
>
> 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.")

Thanks very much!
Re: how to draw contour with continue color? [message #63661 is a reply to message #63657] Sat, 15 November 2008 20:13 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
xqinshan writes:

> Hi, I use "contour...nlevels=..../fill" to get contour plot. The color
> variation is seperated. Although if I set nlevels=50 or more it looks
> better, but the contour color is not continuous. When I donot set
> nleves for "colorbar", the color of colorbar is continuous.But how can
> I do for contour?

You want an image, not a filled contour plot.

data = Dist(300)
step = (Max(data) - Min(data)) / 16.
levels = Indgen(16) * step + Min(data)
Device, Decomposed=1
CTLoad, 4, /Brewer
pos = [0.15, 0.15, 0.9, 0.75]
Erase, Color=FSC_Color('ivory')
TVImage, BytScl(data), POSITION=pos
Contour, data, /NOERASE, POSITION=pos, XSTYLE=1, YSTYLE=1, $
LEVELS=levels, COLOR=FSC_Color('black'), $
C_LABEL=Replicate(1, 16)
Colorbar, NCOLORS=256, RANGE=[Min(data), Max(data)], DIVISIONS=4, $
POSITION=[0.15, 0.8, 0.9, 0.85], /TOP, COLOR=FSC_Color('black')

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: how to draw contour with continue color? [message #63662 is a reply to message #63661] Sat, 15 November 2008 19:57 Go to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
"xqinshan" <xqinshan@tom.com> wrote in message
news:704ac982-d7be-4e4f-b0f0-af9002afa778@v5g2000prm.googleg roups.com...
> Hi, I use "contour...nlevels=..../fill" to get contour plot. The color
> variation is seperated. Although if I set nlevels=50 or more it looks
> better, but the contour color is not continuous. When I donot set
> nleves for "colorbar", the color of colorbar is continuous.But how can
> I do for contour?
> Best,
> Xqinshan

sounds like you do not want a contour plot.
Check out tvimage (from dfanning.com)

Or you could do a shade_surf with az=0, ax=90, shade=bytscl(data) type thing
(with the z axis ticknames = a blank array).

Cheers,
bob
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: read ascii
Next Topic: Philosophical Question about NAN

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

Current Time: Wed Oct 08 15:48:31 PDT 2025

Total time taken to generate the page: 0.00697 seconds