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

Home » Public Forums » archive » Re: Contour Plot with Handful of Colors
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: Contour Plot with Handful of Colors [message #77538] Thu, 08 September 2011 11:49
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> The other common denominator in these programs
> (aside from the fact that Mark wrote them!) is that
> they all seem to be crashing at the Colorbar() function
> call. If I were going to investigate this, that's where
> I would start the investigation. :-)

OK, after *many* reboots (don't worry, I have a murder
mystery on the Kindle!) I have discovered that if I use
the TICKNAME keyword on the Colorbar() function and pass
in a vector of strings that I will immediately and
irrevocably crash my Windows 7, 64-bit OS.

Maybe the ITTVIS guys can pass this along to their
technical support people (who have not gotten back
to me yet today).

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: Contour Plot with Handful of Colors [message #77544 is a reply to message #77538] Thu, 08 September 2011 08:20 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Do I dare run this program!? It is probably a coincidence,
> but I notice that you have written all of my growing list
> of programs that reliably crash my computer! :-)

OK, I have another program for the CRASH-IT! list. :-(

The other common denominator in these programs
(aside from the fact that Mark wrote them!) is that
they all seem to be crashing at the Colorbar() function
call. If I were going to investigate this, that's where
I would start the investigation. :-)

Cheers,

David

P.S. I took the precaution of stepping through this
program, so I could see where it was crashing my
machine.



--
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: Contour Plot with Handful of Colors [message #77546 is a reply to message #77544] Thu, 08 September 2011 08:07 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mark Piper writes:

> It's possible, but you have to mess with the color tables.

Do I dare run this program!? It is probably a coincidence,
but I notice that you have written all of my growing list
of programs that reliably crash my computer! :-)

In other words, it seems to be the work-arounds for doing
simple things that are doing me in. :-(

OK, I'll try this and see what happens. If you don't
hear from me in an hour, you will know. ;-)

Cheers,

David

P.S. What version of IDL do you use, and on what machine?



--
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: Contour Plot with Handful of Colors [message #77547 is a reply to message #77546] Thu, 08 September 2011 07:42 Go to previous message
Mark Piper is currently offline  Mark Piper
Messages: 198
Registered: December 2009
Senior Member
On 9/7/2011 8:45 PM, David Fanning wrote:
> Folks,
>
> I am trying to reproduce a filled contour plot with
> a colorbar with a handful (9, in this case) of colors.
> Does anyone know how to produce a function graphics
> color bar with less than 256 colors? Also, I can't
> get my function graphics filled contour to use the
> colors I am trying to assign to it. :-(
>
> Any ideas?
>

Hi David,

It's possible, but you have to mess with the color tables.

mp

pro ng_discrete_colorbar
compile_opt idl2

; Example function to plot with a range of [0,100].
d = dist(41)
fmax = 100.0
f = d / max(d) * fmax

; Explicitly set 11 contour levels: [0, 10, 20, ... 100].
n_levels = 11
levels = findgen(n_levels)/(n_levels-1)*fmax

; Make a step color table for the contour plot. The color table
'step_ct'
; is a [256,3] array, but there are only n_levels=11 distinct colors (to
; check, load & view the color table in XPALETTE). The indices into
the color
; tables (both original and step) are contour levels interpolated to
the
; range of color table indices (i.e., the byte range).
ct_number = 4
ct_indices = bytscl(levels)
loadct, ct_number, rgb_table=ct, /silent
step_ct = congrid(ct[ct_indices, *], 256, 3)

; Display the example function using the step color table and the
; interpolated indices.
c1 = contour(f, $
c_value=levels, $
rgb_table=step_ct, $
rgb_indices=ct_indices, $
/fill, $
margin=[0.15, 0.20, 0.15, 0.15], $ ; leave room for colorbar
title='Max = ' + strtrim(fmax,2), $
window_title='Discrete Colorbar Example')

; The colorbar needs n_levels+1 ticks for labels to line up correctly.
tick_labels = [strtrim(fix(levels), 2), ''] ; append empty string
cb = colorbar( $
target=c1, $
ticklen=0, $
major=n_levels+1, $
tickname=tick_labels, $
font_size=10, $
position=[0.2, 0.07, 0.8, 0.1])
end
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Direct vs Function Graphics Contour Plots
Next Topic: Need a Coffee Break?

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

Current Time: Wed Oct 08 20:03:10 PDT 2025

Total time taken to generate the page: 0.01346 seconds