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

Home » Public Forums » archive » Re: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles
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: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58580] Thu, 07 February 2008 10:15 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Spon writes:

> Hey, I could always buy a flight to Amsterdam on the card and meet you
> there to hand over the dollars in hard cash- when are you going
> again? ;-)

That would be the most fun. I could sign a copy of the
CD for you.

Unfortunately, if I don't get my desk cleared off in the
next few hours I won't be *able* to go. :-(

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: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58581 is a reply to message #58580] Thu, 07 February 2008 09:49 Go to previous messageGo to next message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Feb 7, 4:55 pm, David Fanning <n...@dfanning.com> wrote:
> Spon writes:
>> Thanks, this is great! It's not a case of it being poorly written (far
>> from it), more like 'well concealed'. :-)
>
> Well, I found it by going to the IDL Tips page, clicking "Color Tips"
> in the menu there, then finding the article "Can you explain how color
> works in IDL?" in the list of color articles. I can't think off-hand
> how I could spell it out any clearer than that. But I'll work on
> it. :-)

Graagh! How did I miss that? Don't mind me, I'm obviously just blind :-
(

It does seem odd that I can buy flights for several hundreds of euros
with my debit card, yet I'm unable to buy a $25 pdf file just because
it comes from a different continent. I've had a similar experience
with amazon - .ie, .co.uk and .de are all happy to take Maestro,
but .com just refuses. Maybe it's just my weird bank?
I know these are all large corporations and can *theoretically* be
trusted to keep my personal data safe, which may be more difficult for
something like paypal to prove about the vendors that use it.

Hey, I could always buy a flight to Amsterdam on the card and meet you
there to hand over the dollars in hard cash- when are you going
again? ;-)

All the best,
Chris
Re: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58582 is a reply to message #58581] Thu, 07 February 2008 09:19 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

>> Reminded me again of how I really need to borrow someone's credit card
>> sometime soon. PayPal doesn't like debit cards - even ones that the
>> bank sends you a whole tree's worth of (snailmail) spam about, making
>> claims about how universally accepted they are :-(
>
> Humm. I don't know. I'll see what I can find out about this.

Most of the companies that process Internet merchant accounts
don't allow Internet debit cards. (You have to be a retail
merchant, with the debit card in your hand.) They don't
say why this is, but I presume it is a security issue. I
wouldn't be surprised to learn that it is harder to recover
from a fraudulent transaction when a debit card is used than
from a fraudulent credit card transaction.

In any case, in a quick search, I couldn't find any merchant
account that would allow me to process debit cards in my
business, unless you show up in my bedroom office. :-)

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: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58583 is a reply to message #58582] Thu, 07 February 2008 08:55 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Spon writes:

> Thanks, this is great! It's not a case of it being poorly written (far
> from it), more like 'well concealed'. :-)

Well, I found it by going to the IDL Tips page, clicking "Color Tips"
in the menu there, then finding the article "Can you explain how color
works in IDL?" in the list of color articles. I can't think off-hand
how I could spell it out any clearer than that. But I'll work on
it. :-)

> I can't find links to this from anywhere on your site, and the search
> feature doesn't find it either.

What search terms did you try to use? The search "how does color work"
gets you right there. I do notice that the search "IDL colors" turns
up thousands of articles on the page, which may be too many. :-(
See the delightful book "The Paradox of Choice" in my book reviews
for the reason why.

> Mind you, if it's a chapter from your book that you quite rightly
> charge for, it's no wonder you're not waving it about for free. Or
> should I say, you weren't...

Oh, hell, I'm not about money. Just don't tell my wife, please.

> Reminded me again of how I really need to borrow someone's credit card
> sometime soon. PayPal doesn't like debit cards - even ones that the
> bank sends you a whole tree's worth of (snailmail) spam about, making
> claims about how universally accepted they are :-(

Humm. I don't know. I'll see what I can find out about this.

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: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58584 is a reply to message #58583] Thu, 07 February 2008 08:31 Go to previous messageGo to next message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Feb 7, 2:58 pm, David Fanning <n...@dfanning.com> wrote:
> Oh, dear. Doesn't anyone read the articles I put on my
> web page anymore, or are they just so poorly written no
> one cares!? :-(
>
> But, do yourself a favor, and at least read this article:
>
> http://www.dfanning.com/color_tips/working_with_color.pdf

Thanks, this is great! It's not a case of it being poorly written (far
from it), more like 'well concealed'. :-)
I can't find links to this from anywhere on your site, and the search
feature doesn't find it either.

Mind you, if it's a chapter from your book that you quite rightly
charge for, it's no wonder you're not waving it about for free. Or
should I say, you weren't...

Reminded me again of how I really need to borrow someone's credit card
sometime soon. PayPal doesn't like debit cards - even ones that the
bank sends you a whole tree's worth of (snailmail) spam about, making
claims about how universally accepted they are :-(

> Since this article is already longer than the two lines most
> people tend to read, I won't go into the details of how to
> create a PNG file in the Z-buffer, except to say Chris is
> right, use TVREAD. It will solve all your problems.

Took me long enough to get there though :-(

> Cheers,
>
> David

Take care,
Chris
Re: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58587 is a reply to message #58584] Thu, 07 February 2008 06:58 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Spon writes:

> I'm sure David (most likely) will be along shortly with an explanation
> of how to solve your problem in a much more sensible way, and will do
> so more eloquently than I could - even if I knew how ;-)

Oh, dear. Doesn't anyone read the articles I put on my
web page anymore, or are they just so poorly written no
one cares!? :-(

But, do yourself a favor, and at least read this article:

http://www.dfanning.com/color_tips/working_with_color.pdf

This code is so dead simple that the only reason it
doesn't work is that just about everything is done wrong. :-)

Here are a couple of rules:

1. If you care about PostScript color, don't use the color
indices at the top and bottom of the color table to specify
any of them. Specifically, don't use !P.COLOR and
!P.BACKGROUD, since these are almost always pointed to the
top and bottom of the color table.

2. There are commands, such as WINDOW and ERASE, that we
often find in programs that work great in a display device,
but which either don't work or work differently (and
disastrously, usually) in the PostScript device. These
have to be protected. They are usually protected like this:

IF (!D.FLAGS AND 256) NE 0 THEN Window

This modified program will work on your display and in
PostScript, *if* you set your PostScript device up correctly,
which I have my doubts about, but see more below:

pro plot_test, indices, color_scale,$
title=title

if n_elements(title) eq 0 then title=''

; example simple grid of 4 points:
x_pos=[1., 2., 1., 2.]
y_pos=[1.,1.,2.,2]

; Load colors for the plot
tvlct, 255, 255, 255, 0, 10 ; White loaded at color index 10
tvlct, 0, 0, 0, 11 ; Black loaded at color index 11

; Indexed color on your display device, skip if in PS
if (!d.flags and 256) ne 0 then Device, decomposed = 0

;plot, the center points for each detector:
plot, x_pos, y_pos, xrange=[0,3],yrange=[0,3],
/xstyle,/ystyle,/iso,psym = 3, title = title,
color=11, background=10

; Load the colors for the polyfill and color bar.

LoadCT, 33
; determine the color scale to use
color_scale=float(color_scale)

color_values = ((color_scale - min(color_scale))/(max(color_scale)-
min(color_scale)))* 255

;plot circles filled with the colors in the scale
for I=0,n_elements(indices)-1 do begin
polyfill, circle(x_pos[indices[I]],y_pos[indices[I]],0.25),
color=color_values[I]
endfor

colorbar, /vertical, format='(F6.2)',$
range=[min(color_scale),max(color_scale)],
annotatecolor='black'

;or, alternatively...
;
; load colors for the colorbar.
;loadct, 33, ncolors=253
;tvlct, 0, 0, 0, 254
;colorbar, /vertical, format='(F6.2)',$
; range=[min(color_scale),max(color_scale)],
; color=254, ncolors=253

end


3. Make sure your PostScript device is set up correctly.
If you insist on not using PSCONFIG to do this (and I don't
know why this is the case, since this program was designed
to be so dead simple that it solves 90% of PostScript problems
before you even know they are problems), then at least be
sure you set BITS_PER_PIXEL=8 and COLOR=1. This is almost
certainly why your PostScript output is "grainy".

You can find probably another dozen rules of so, discussed
in excruciating detail, on my web page:

http://www.dfanning.com/documents/tips.html#PostScript



Having said all this, I certainly wouldn't use PostScript to
solve this problem. :-)

If the Z-Graphics buffer doesn't accept the DEVICE, DECOMPOSED=0
command, then you are using an old version of IDL. But, in any
case, you now know how to protect this command. :-)

Since this article is already longer than the two lines most
people tend to read, I won't go into the details of how to
create a PNG file in the Z-buffer, except to say Chris is
right, use TVREAD. It will solve all your problems.

In fact, all your problems would be solved by judicious use
of these four programs:

PSCONFIG
FSC_COLOR
TVREAD
TVIMAGE

These were created to *specifically* solve PostScript problems
and make it easy to write programs that just work *everywhere*. :-)

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: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58588 is a reply to message #58587] Thu, 07 February 2008 06:16 Go to previous messageGo to next message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
I think the answer to all your problems might be here:

http://www.dfanning.com/color_tips/howjpeg.html

TVREAD is here:
http://www.dfanning.com/programs/tvread.pro

As far as I can tell it'll create a PNG file of a window's contents
straight from your X buffer. Bing. Problem solved.

Let me know if it works, please :-)
Chris
Re: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58590 is a reply to message #58588] Thu, 07 February 2008 06:02 Go to previous messageGo to next message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Feb 7, 1:21 pm, "kathryn....@gmail.com" <kathryn....@gmail.com>
wrote:
> I think the main reason I'm having so much trouble here is I'm trying
> to get something to work with color tables and true-color display
> without really understanding them.

I agree. Can you tell that I don't either? I'm learning though. :-)

> My image quality is degraded and the text is grainy,

Ah... I should've seen that coming :-(

http://www.dfanning.com/tips/postscript24.html

I *think* that by calling LOADCT in this instance you're actually
specifying every single colour as a 24-bit value. Which you can't.

Off the top of my head, I'd try defining my colour table before
changing device, and then seeing if POLYFILL and COLORBAR accept the
TRUE keyword. Don't have the time to check this right now, sorry.

I'm sure David (most likely) will be along shortly with an explanation
of how to solve your problem in a much more sensible way, and will do
so more eloquently than I could - even if I knew how ;-)

Good luck!
Chris
Re: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58591 is a reply to message #58590] Thu, 07 February 2008 05:21 Go to previous messageGo to next message
kathryn.ksm is currently offline  kathryn.ksm
Messages: 10
Registered: April 2006
Junior Member
Hi Chris,

Thanks for your suggestion. I don't have a lot of experience with the
ps device either, which is part of why my attempts to use the ps
option have been shots in the dark. Your suggestion does give me a
quick fix. My image quality is degraded and the text is grainy,
though, and there is something unsatisfying about having to do an
image format conversion afterwards. I'm still holding out for
suggestion for how to solve this problem with the Z buffer or
something clever... but until then I'll implement this and at least
I'll have something that basically works.

Thanks again,

Kathryn
Re: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58592 is a reply to message #58591] Thu, 07 February 2008 03:10 Go to previous messageGo to next message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Feb 7, 10:06 am, "kathryn....@gmail.com" <kathryn....@gmail.com>
wrote:
> Hi folks,
>
> This newsgroup has been a huge help to me with these sorts of problems
> in the past, and I am hoping once again to draw on your expertise.
>
> My problem is a little complicated. I have a particular plotting
> routine that uses a color scale to represent signal response over a
> grid of detectors. I use this a lot and it's really handy. It also
> took me a really long time to get it to work and to be able to
> write_png files from it without getting goofy colors. What I would
> like to do is automate this routine and run it with a cron job,
> outputting png files to include in a daily web page.
>
> I have noticed that quite a few people have tried to do similar things
> and run into problems. I have problems with all of the suggested
> solutions. Any one of them would be fine but I can't get them to
> work. So here goes:
>
> option 1) use the Z buffer: Here I think I am running into problems
> with my understanding of true-color display issues in IDL. My plot
> routine includes a line 'Device, decomposed = 0' and the Z-buffer
> doesn't work the same way as the X buffer. That's problem number
> one. Problem number two is that I can't figure out how to take the Z-
> buffer plot and make a png file out of it with correct colors.
>
> option 2) write to a ps file and convert it to png after the fact. I
> have similar problems here with my Device, decomposed = 0, and I don't
> understand how to translate my plotting routine so that it will do the
> same thing with the ps device that it does with standard X output.
>
> option 3) use the /pixmap option with an X window, and then use Xvfb
> to run a virtual X session so that I can run this from cron. I have
> Xvfb installed and with some fiddling, I can get the authentication to
> work out so that I don't get an immediate Xlib: connection to ":1.0"
> refused by server, but even then I still get WINDOW: Unable to connect
> to X Windows display: :1.0 errors, even though the DISPLAY variable
> looks to be set correctly to me. I really hoped I could get this to
> work, because doing window, 1, /pixmap, running the plotter, and then
> calling write_png, 'file.png', tvrd(/true) works wonderfully and gives
> exactly what I want... just not through cron.
>
> I think the main reason I'm having so much trouble here is I'm trying
> to get something to work with color tables and true-color display
> without really understanding them. A stripped-down version of the
> plotting routine is below. I would invoke it with something like>plot_test, [0,2,3],[0.2,0.7,1.0]. Before I run this, I have quite a
>
> few graphics setup calls in my idl_startup file. Between running it,
> I typically do
> loadct, 0
> !p.color = !black
> !p.background = !white
> to make the display look right each time.
>
> Sorry for the long-winded question. Sample plotting routine follows:
>
> pro plot_test, indices, color_scale,$
> title=title
>
> if n_elements(title) eq 0 then title=''
>
> ; example simple grid of 4 points:
> x_pos=[1., 2., 1., 2.]
> y_pos=[1.,1.,2.,2]
>
> ;plot, the center points for each detector:
> plot, x_pos, y_pos, xrange=[0,3],yrange=[0,3],/xstyle,/ystyle,/iso,$
> psym = 3, title = title
> Device, decomposed = 0
> LoadCT, 33
> ; determine the color scale to use
> color_scale=float(color_scale)
>
> color_values = ((color_scale - min(color_scale))/(max(color_scale)-
> min(color_scale)))* 255
>
> ;plot circles filled with the colors in the scale
> for i=0,n_elements(indices)-1 do begin
> polyfill, circle(x_pos[indices[i]],y_pos[indices[i]],0.25),
> color=color_values[i]
> endfor
>
> colorbar, /vertical, format='(F6.2)',$
> range=[min(color_scale),max(color_scale)]
>
> end
>
> - Kathryn

This may be a clumsy way of going about it, I admit I've not had to
use PostScript output much, but what happens if you replace:

Device, decomposed = 0
With:

IF !D.NAME EQ 'PS' THEN DEVICE, /COLOR, BITS = 8 ELSE DEVICE,
DECOMPOSED = 0

(assuming you've already set your filename when you called SET_PLOT if
you're using postscript)

As far as I can work out, LOADCT should work just like TVLCT in
Postscript mode, no?

If I'm wrong about this, I'd love to know why - I'm posting this to
learn as much as anything :-)

Anyway, hope it helps,
Chris
Re: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58656 is a reply to message #58592] Fri, 08 February 2008 10:18 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
kathryn.ksm@gmail.com writes:

> I am actually not using FSC_COLOR but I noticed the
> recently-added CRONJOB option, which is awesome. I managed to get
> things to work with the COLORBAR using the COLOR option instead of
> ANNOTATECOLOR. I haven't tested it yet, but I had a feeling that the
> FSC_COLOR call in the ANNOTATECOLOR might cause problems in cron jobs
> if the CRONJOB keyword isn't propagated through somehow.

I think you may be right about this. But if you
understand color tables now, ANNOTATECOLOR isn't
needed. That was just there for the newbies. :-)

The basic rule is simple: if you want the right
colors, load them just before you draw something.
Then, you are *always* right.

Except with printers, of course, but... let's leave
that for another day.

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: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58657 is a reply to message #58592] Fri, 08 February 2008 10:02 Go to previous message
kathryn.ksm is currently offline  kathryn.ksm
Messages: 10
Registered: April 2006
Junior Member
On Feb 8, 10:52 am, David Fanning <n...@dfanning.com> wrote:
> Katheryn writes:
>> So, I am still a little confused. The reason for using a color table
>> in the first place is so that I can do the neat trick of scaling the
>> colors in my plots to represent some arbitrary distribution of values
>> over an arbitrary range, which is the purpose of the actual version of
>> this little plotter. Is there a way to do that either with FSC_COLOR
>> or some version of color tables in the Z buffer and get the colors I
>> really want out?
>
> You load color tables in the usual way with LOADCT,
> although you might want to become acquainted with the
> keywords NCOLORS and BOTTOM as you gain more experience
> with this.
>
> Your problem is that the color table you want to
> use to display your data (33) is about the worst possible
> choice to use in drawing a plot, since--as you see--
> it typically results in a blue background with red
> axes. Yuck!
>
> The code I wrote for you yesterday loads some plot
> drawing colors into the color table, draws the plot
> with something sensible, then loads color table 33
> to draw your data. That is one way to handle the
> situation. The other way, if you insist on using
> indexed color, and--alas--you have to in the PostScript
> device, is to divide your color table up into "plot
> drawing colors" and "data display colors".
>
> For example, you could do this:
>
> LoadCT, 33, NCOLORS=250
> TVLCT, FSC_COLOR(['white', 'navy', 'indian red'], /TRIPLE), 250
>
> This gives me 250 "display colors" and three "plotting colors",
> while are loaded in indices 250, 251, and 252. Now, all I have
> to do is make sure I scale my data into only 250 values, so I
> can get the correct color display, and I am good to go:
>
> !P.Multi=[0,2,1]
> data = BytScl(dist(256), Top=249)
> Plot, findgen(11), color=251, background=250, /nodata
> Oplot, findgen(11), color=252
> TVImage, data
> !P.Multi = 0
>
> This assumes you are using indexed color, of course. If you
> wanted to do this in a color set-up independent way, you would
> use FSC_COLOR to specify the colors on your plot commands.
> For example, if I wanted my program to display the correct
> results on my display (whether I was using decomposed color
> or not) and in PostScript and in the Z-buffer and ... wherever,
> I would write the code like this:
>
> !P.Multi=[0,2,1]
> data = Bytscl(dist(256))
> Plot, findgen(11), color=fsc_color('navy'), $
> background=fsc_color('white'), /nodata
> Oplot, findgen(11), color=fsc_color('indian red')
> LoadCT, 33
> TVImage, data
> !P.Multi = 0
>
> Notice here, I don't have to restrict the number of colors
> for my data, I can use all 256 I have loaded.
>
> A handy way to check which colors you have loaded in your
> color table is to use CINDEX, another Coyote Library program
> you have downloaded by now. :)
>
> 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.")


David,

There went the 'aha'. I get it now... I tried out something along the
lines of your suggestions (assigning the colors for the plot
separately from those used to represent data) and that works - even
with cron. I am actually not using FSC_COLOR but I noticed the
recently-added CRONJOB option, which is awesome. I managed to get
things to work with the COLORBAR using the COLOR option instead of
ANNOTATECOLOR. I haven't tested it yet, but I had a feeling that the
FSC_COLOR call in the ANNOTATECOLOR might cause problems in cron jobs
if the CRONJOB keyword isn't propagated through somehow. But anyway,
I just made my first lovely color image using cron. Phew! Thanks
gazillions,

Kathryn
Re: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58664 is a reply to message #58592] Fri, 08 February 2008 08:52 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Katheryn writes:

> So, I am still a little confused. The reason for using a color table
> in the first place is so that I can do the neat trick of scaling the
> colors in my plots to represent some arbitrary distribution of values
> over an arbitrary range, which is the purpose of the actual version of
> this little plotter. Is there a way to do that either with FSC_COLOR
> or some version of color tables in the Z buffer and get the colors I
> really want out?

You load color tables in the usual way with LOADCT,
although you might want to become acquainted with the
keywords NCOLORS and BOTTOM as you gain more experience
with this.

Your problem is that the color table you want to
use to display your data (33) is about the worst possible
choice to use in drawing a plot, since--as you see--
it typically results in a blue background with red
axes. Yuck!

The code I wrote for you yesterday loads some plot
drawing colors into the color table, draws the plot
with something sensible, then loads color table 33
to draw your data. That is one way to handle the
situation. The other way, if you insist on using
indexed color, and--alas--you have to in the PostScript
device, is to divide your color table up into "plot
drawing colors" and "data display colors".

For example, you could do this:

LoadCT, 33, NCOLORS=250
TVLCT, FSC_COLOR(['white', 'navy', 'indian red'], /TRIPLE), 250

This gives me 250 "display colors" and three "plotting colors",
while are loaded in indices 250, 251, and 252. Now, all I have
to do is make sure I scale my data into only 250 values, so I
can get the correct color display, and I am good to go:

!P.Multi=[0,2,1]
data = BytScl(dist(256), Top=249)
Plot, findgen(11), color=251, background=250, /nodata
Oplot, findgen(11), color=252
TVImage, data
!P.Multi = 0

This assumes you are using indexed color, of course. If you
wanted to do this in a color set-up independent way, you would
use FSC_COLOR to specify the colors on your plot commands.
For example, if I wanted my program to display the correct
results on my display (whether I was using decomposed color
or not) and in PostScript and in the Z-buffer and ... wherever,
I would write the code like this:

!P.Multi=[0,2,1]
data = Bytscl(dist(256))
Plot, findgen(11), color=fsc_color('navy'), $
background=fsc_color('white'), /nodata
Oplot, findgen(11), color=fsc_color('indian red')
LoadCT, 33
TVImage, data
!P.Multi = 0

Notice here, I don't have to restrict the number of colors
for my data, I can use all 256 I have loaded.

A handy way to check which colors you have loaded in your
color table is to use CINDEX, another Coyote Library program
you have downloaded by now. :)

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: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58666 is a reply to message #58592] Fri, 08 February 2008 08:25 Go to previous message
kathryn.ksm is currently offline  kathryn.ksm
Messages: 10
Registered: April 2006
Junior Member
On Feb 8, 10:06 am, David Fanning <n...@dfanning.com> wrote:
> Kathryn writes:
>> For example, if I use the modified version of my stupid plotting
>> procedure that was in David's reply (running interactively, using X
>> windows), I have a couple of additional problems. First, I downloaded
>> FSC_COLOR so that I could use the annotatecolor option to colorbar.
>> However, the call as it stands in colorbar (which I also just re-
>> downloaded, to make sure I had the current version) leaves me with a
>> syntax error in FSC_COLOR, supposedly to do with the filename argument
>> in the call:
>> theColor = PickColorName(Filename=filename, _Extra=extra,
>> Cancel=cancelled)
>
> More likely that PickColorName is not in your path. Maybe
> you didn't download it. I use the Library to build programs
> in the Library, so...
>
> http://www.dfanning.com/programs/coyoteprograms.zip
>
>
>
>> Furthermore, if I try to use the Z buffer and TVREAD to solve my
>> problem, for example:
>> set_plot, 'Z'
>> plot_test, [0,2],[0.3,2.5]
>> tvread(/png, filename='plot_test',/nodialog)
>
>> My plot comes out with a blue background, invisible axes, and red
>> annotation on the colorbar. So clearly I'm still missing something
>> with respect to specifying the colors.
>
> Well, I think you forgot to specify them. This would be what
> I would expect for that color table 33 you were using the other
> day and this code.
>
> Something like this should work better:
>
> set_plot, 'Z'
> tvlct, 255, 255, 255, 1 ; White
> tvlct, 0, 0, 128, 2 ; Navy Blue
> tvlct, 205, 92, 92, 3, ; Indian Red
> Plot, [0,2],[0.3,2.5], Background=1, Color=2, /NoData
> OPlot, [0,2],[0.3,2.5], Color=3
> void = tvread(/png, filename='plot_test',/nodialog)
>
>> To be sure I wasn't screwing something up with calls in my
>> startup file, I commented out all graphics-related things prior to
>> testing the above snippet.
>
> There's your problem! ;-)
>
>> Thanks to everyone on this newsgroup for always being so generous with
>> suggestions,
>
> I thought I might have been too harsh yesterday in my assessment
> of your program, but you seem to be bucking up. Hang in there,
> you are just an Ah-ha moment away! :-)
>
> 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.")


Hi again David,

You weren't too harsh at all - I'm just trying to hack my way to a
solution to a problem as fast as possible. I know it ain't pretty.

So, I am still a little confused. The reason for using a color table
in the first place is so that I can do the neat trick of scaling the
colors in my plots to represent some arbitrary distribution of values
over an arbitrary range, which is the purpose of the actual version of
this little plotter. Is there a way to do that either with FSC_COLOR
or some version of color tables in the Z buffer and get the colors I
really want out?

Thanks tons,

Kathryn
Re: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58667 is a reply to message #58592] Fri, 08 February 2008 08:06 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kathryn writes:

> For example, if I use the modified version of my stupid plotting
> procedure that was in David's reply (running interactively, using X
> windows), I have a couple of additional problems. First, I downloaded
> FSC_COLOR so that I could use the annotatecolor option to colorbar.
> However, the call as it stands in colorbar (which I also just re-
> downloaded, to make sure I had the current version) leaves me with a
> syntax error in FSC_COLOR, supposedly to do with the filename argument
> in the call:
> theColor = PickColorName(Filename=filename, _Extra=extra,
> Cancel=cancelled)

More likely that PickColorName is not in your path. Maybe
you didn't download it. I use the Library to build programs
in the Library, so...

http://www.dfanning.com/programs/coyoteprograms.zip

>
> Furthermore, if I try to use the Z buffer and TVREAD to solve my
> problem, for example:
> set_plot, 'Z'
> plot_test, [0,2],[0.3,2.5]
> tvread(/png, filename='plot_test',/nodialog)
>
> My plot comes out with a blue background, invisible axes, and red
> annotation on the colorbar. So clearly I'm still missing something
> with respect to specifying the colors.

Well, I think you forgot to specify them. This would be what
I would expect for that color table 33 you were using the other
day and this code.

Something like this should work better:

set_plot, 'Z'
tvlct, 255, 255, 255, 1 ; White
tvlct, 0, 0, 128, 2 ; Navy Blue
tvlct, 205, 92, 92, 3, ; Indian Red
Plot, [0,2],[0.3,2.5], Background=1, Color=2, /NoData
OPlot, [0,2],[0.3,2.5], Color=3
void = tvread(/png, filename='plot_test',/nodialog)

> To be sure I wasn't screwing something up with calls in my
> startup file, I commented out all graphics-related things prior to
> testing the above snippet.

There's your problem! ;-)

> Thanks to everyone on this newsgroup for always being so generous with
> suggestions,

I thought I might have been too harsh yesterday in my assessment
of your program, but you seem to be bucking up. Hang in there,
you are just an Ah-ha moment away! :-)

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: An IDL cron job, true color plots, Xvfb, Z-buffer, and all sorts of troubles [message #58668 is a reply to message #58587] Fri, 08 February 2008 07:42 Go to previous message
kathryn.ksm is currently offline  kathryn.ksm
Messages: 10
Registered: April 2006
Junior Member
Howdy,

Thanks for all of the suggestions. I confess to being absolutely
stupid when it comes to IDL colors and plotting - and I have actually
read a fair amount of what's out there. I know I must be really
idiotic about this subject, because I always have a hell of a time
reproducing the expected output from the tricks I see online.

For example, if I use the modified version of my stupid plotting
procedure that was in David's reply (running interactively, using X
windows), I have a couple of additional problems. First, I downloaded
FSC_COLOR so that I could use the annotatecolor option to colorbar.
However, the call as it stands in colorbar (which I also just re-
downloaded, to make sure I had the current version) leaves me with a
syntax error in FSC_COLOR, supposedly to do with the filename argument
in the call:
theColor = PickColorName(Filename=filename, _Extra=extra,
Cancel=cancelled)

Furthermore, if I try to use the Z buffer and TVREAD to solve my
problem, for example:
set_plot, 'Z'
plot_test, [0,2],[0.3,2.5]
tvread(/png, filename='plot_test',/nodialog)

My plot comes out with a blue background, invisible axes, and red
annotation on the colorbar. So clearly I'm still missing something
with respect to specifying the colors. I like the idea of using the Z
buffer and TVREAD much better than the postcript option, but I think
this problem was what actually made me abandon it the first time I
tried. To be sure I wasn't screwing something up with calls in my
startup file, I commented out all graphics-related things prior to
testing the above snippet.

I realize the answers to these questions are probably out there
someplace... but trust me, if you had the internet connectivity I
currently do (at a remote research station), extensive browsing would
drive you even more batty than running in circles with IDL's colors...

Thanks to everyone on this newsgroup for always being so generous with
suggestions,

Kathryn
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Multi bands mean
Next Topic: Singing New Tune

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

Current Time: Wed Oct 08 19:17:00 PDT 2025

Total time taken to generate the page: 0.00523 seconds