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

Home » Public Forums » archive » Re: simplest contour & .png
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: simplest contour & .png [message #80009 is a reply to message #80008] Thu, 26 April 2012 07:12 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Leslie Moy writes:

> It seems like it should be easy...

Oh, it *always* seems so. :-)

> I have a 2D array C(20,20) and i want to make a simple figure with
> 20x20 colored boxes. I started with a CG contour template but have two
> questions.
>
> 1. i assumed there must be a command to Not make it contour and just
> put in a colored box. is there such a thing? or am i starting out
> wrong with 'contour'?

There is such a thing, but it is called an "image".

> 2. i want to output to a .png file. but i get two figures with my code
> below - one of the contour plot, the other of the colorbar. normally i
> would think to add in /overplot to cgcolorbar but that gives me an
> error.

The keyword you are looking for is AddCmd, not Overplot. You want to
"add" the "command" to the resizeable cgWindow.

>
> cgwindow
> nlevels=12
> loadct,33,ncolors=nlevels,bottom=1
> step=(max(C)-min(C))/nlevels
> levels=indgen(nlevels)*step+min(C)
> setdecomposedstate,0,currentstate=currentstate

No reason whatsoever to set yourself up in indexed color
mode if you are using Coyote Graphics routines. They
will work best in decomposed color mode and, in fact, most
of them work in that mode anyway. Including the cgContour
command. So this SetDecomposedState command has NO effect
whatsoever.

>
> cgcontour,C,/fill,Levels=levels,position=[0.125,0.125,0.95,0 .8],$
> background=cgcolor('white'),color=cgcolor('black'),$
> xstyle=1,ystyle=1,c_colors=indgen(nlevels)+1,/window
>
> setdecomposedstate,currentstate
> cgcolorbar,range=[min(C),max(C)],divisions=12,xticklen=1,xmi nor=0,$
> annotatecolor='black',ncolors=12,bottom=1, $
>
> position=[0.125,0.915,0.955,0.95],charsize=1.00,format='(F0. 4)'
>
> cgcontrol,create_png='tt.png'

The code you want probably looks more like this:

cgLoadCT, 33
cgImage, C, /Scale, /Axes, Position=[0.125,0.125,0.95,0.8], /Window
cgColorbar, Range=[min(C),max(C)],Divisions=12, XTicklen=1, $
XMinor=0, Position=[0.125,0.915,0.955,0.95],$
Charsize=1.00, Format='(F0.4)', /AddCmd
cgControl, Output='tt.png'

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: How to make an input parameters file??
Next Topic: IDL v7.0 "native" colourbar procedure?

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

Current Time: Wed Oct 08 19:29:59 PDT 2025

Total time taken to generate the page: 0.00471 seconds