Re: Using Postscript & Colours in IDL [message #58323] |
Mon, 28 January 2008 07:12  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
chloesharrocks@gmail.com writes:
> I've
> only recently started using IDL, so am ideally looking for something
> very basic - I just want to be able to have red/blue/green plots with
> white background and black text/axis.
In all seriousness, I've slowing been coming to the
realization that IDL is not the Be-All and End-All in
scientific visualization software. In your case, the
ubiquitous Excel might be just what you want. And
probably cheaper, too. :-)
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: Using Postscript & Colours in IDL [message #58324 is a reply to message #58323] |
Mon, 28 January 2008 07:10   |
chloesharrocks
Messages: 16 Registered: January 2008
|
Junior Member |
|
|
Hi David
Sorry, I know I'm being really slow/annoying, but I'm still completely
lost! I have tried using Liam Gumley's book (I have it in front of me
as I type), but am still completely lost with using colours in
postscript output (I can't follow his examples because I don't
understand the basics - I don't know the difference between an 8-bit
mode or 24-bit display etc.
So I've copied fsc_color.pro and all of the contents of the
fsc_psconfigure.zip into a directory called "color" and have used
preferences to add that folder to the IDL path. I'm now trying to
just do a very basic linear plot in which the line is 'indian red':
=====
PRO COLOR_PLOT
x=[0,1,2,3,4]
y=[0,2,4,6,8]
entry_device=!d.name
keywords = PSCONFIG(Cancel=cancelled)
IF cancelled THEN RETURN
set_plot, 'PS'
device, /color, filename='colorplot/ps'
plot, x, y, color=FSC_COLOR('indian red')
device, /close
set_plot, entry_device
END
======
However, I keep getting an error message when I try to compile - it
says there's a syntax error on the line beginning "keywords". I'm so
confused! Is this trying to configure the postscript device! Sorry
again for asking questions that must seem very naive, but to someone
who doesn't have a clue what they're doing they're just questions
desperately trying to understand something very simple!
Thanks
Chloé
|
|
|
Re: Using Postscript & Colours in IDL [message #58328 is a reply to message #58324] |
Mon, 28 January 2008 06:45   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
chloesharrocks@gmail.com writes:
> PS. What do you mean by a "postscript device" (as I said - COMPLETE
> NOVICE HERE!)? Is that referring to the software I use to open the ps
> files or something else entirely?
IDL draws graphics commands to a "graphics device". There
are several kinds of "graphics devices". One is your display,
which is probably named "X", another is PostScript, named
"PS", another is the Z-graphics buffer, named "Z", etc.
IDL can only draw graphics to one graphics device at a
time. The one that is being used currently is stored
in !D.NAME. So, to find out which one you are using (that
is to say, where your graphics are going to go), type
this:
IDL> Print, !D.Name
You select other graphics devices with the SET_PLOT
command:
IDL> Set_Plot, 'PS'
IDL> Set_Plot, 'X'
IDL> Set_Plot, 'Z'
You use the DEVICE command to "control" the graphics device.
That is, to set it's properties and the way it works. But,
the keywords you can use with DEVICE depend entirely on which
graphics device is the current one when you issue your DEVICE
command. (This is why your DEVICE, DECOMPOSED=0 command sometimes
works and sometimes doesn't. Sometimes you are using a device that
supports it and sometimes you aren't. You have to know when you
are and when you aren't!)
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: Using Postscript & Colours in IDL [message #58329 is a reply to message #58328] |
Mon, 28 January 2008 06:38   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
chloesharrocks@gmail.com writes:
> This is probably an incredibly stupid question (but I'm a complete
> programming novice!), but how do I actually use your program? I
> presume I have to copy the fsc_color.pro into IDLDE and save that as a
> program, but then how do I load that program within my code?
>
> Sorry for the basic questions, but I don't have a clue what I'm doing
> and really need a simple step-by-step guide!
Oh, well, then you need the book, too. ;-)
You just copy these programs into a directory (I've named
mine "coyote") that is located somewhere IDL can find them.
This means somewhere on your IDL path (!PATH). Usually,
you just copy them into a directory, and add the directory
to your path. (Somewhere under Preferences, depending upon
what version of IDL you are using.)
You use the programs like you use any other command in IDL.
thisDevice = !D.Name
keywords = PSCONFIG(Cancel=cancelled)
IF cancelled THEN RETURN
Set_Plot, 'PS'
Device, _EXTRA=keywords
Plot, findgen(11), Color=FSC_COLOR('navy', /NODATA, $
BACKGROUND=FSC_COLOR('ivory')
Oplot, findgen(11), Color=FSC_COLOR('indian red')
etc....
Device, /CLOSE
Set_Plot, thisDevice
There will be directions and examples in the headers of all
the files. Ask if you don't understand something.
You will find a book helpful. If you don't know anything at
all about programming, I would recommend Ken Bowman's book.
If you know a little, but don't know anything at all about
IDL, I would recommend either Liam Gumley's book or mine.
You can learn more about them here:
http://www.dfanning.com/documents/books.html
http://www.dfanning.com/documents/book_recommendations.html
My book is available in a PDF format. And I always give
students big discounts on the hardcopy if they ask. :-)
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: Using Postscript & Colours in IDL [message #58332 is a reply to message #58331] |
Mon, 28 January 2008 05:22   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
chloesharrocks@gmail.com writes:
> Most of the time this works fine, but occaisionally when I run the
> program it comes up with an error on the "device, decomposed=3D0" line.
> However, if I shut down IDL and restart it it will work fine again.
> Also, although "color=3D4" looks lime green on my computer, when I print
> it, the colour is more of a bluey-turquoise colour and similarly the
> "color=3D5" which is red looks magenta when printed (is this likely to
> be to do with the printer?). If someone, could explain to me how to
> incorporate colour into postscript files in a way that doesn't cause
> this error every time I'd be most grateful. This is my first time
> using IDL and my first ever encounter with postscript files (I'm an
> undergraduate at Uni).
You don't need to set DECOMPOSED=0 in a PostScript device.
PostScript *is* an 8-bit device (sigh...) so it is automatically
in no-decomposed or indexed color all the time. And, anyway,
this is not an allowed keyword when your device is PostScript.
So, the problem is not that is doesn't work sometime, it
is that it works *any time*. :-)
There are several commands (WINDOW is another) that you
sometimes like to have in a program that shows up on your
display, but you don't want (or can't have) in a program that
is suppose to draw its contents in a PostScript file. In
general, you protect these commands in your code by doing
something like this:
IF (!D.Flags AND 256) NE 0 THEN Device, Decomposed=0
When display colors (produced with light) don't look like
printed colors (produced with dyes and inks), the solution
is to purchase a $25K monitor and a $5K calibration setup
and make sure you know how to use them. I'm saying, this
may be a problem you have to live with unless your research
gets you big contracts with the fashion layout folks.
PostScript is more complicated than it needs to be in IDL,
and it doesn't help newbies when they find the PS way of
doing things is still back in the 1970's. (Which you would
discover if you tried to display an image, since you aren't
setting the BITS_PER_PIXEL keyword on the DEVICE command
to 8 either. Your images will look sickly, but I would
blame this on ITTVIS and not you.)
There are lots of articles about PostScript color on my web
page:
http://www.dfanning.com/documents/tips.html#PostScript
But, since you are new to this, I would *seriously* recommend
you download a couple of programs (well, *all* of them, really!)
from my web page, as they were written *especially* to solve
PostScript and wacky color problems. Here are the ones I couldn't
live without:
http://www.dfanning.com/programs/tvimage.pro
http://www.dfanning.com/programs/tvread.pro
http://www.dfanning.com/programs/fsc_color.pro
http://www.dfanning.com/programs/fsc_psconfig.zip
If you use PSCONFIG to set up your PostScript device you will
probably never encounter most of the problems that stop the
new IDL user dead in their tracks. :-)
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: Using Postscript & Colours in IDL [message #58334 is a reply to message #58333] |
Mon, 28 January 2008 02:08   |
Norbert Hahn
Messages: 46 Registered: May 2003
|
Member |
|
|
chloesharrocks@gmail.com wrote:
> Hi
>
> I'm new to IDL and the concept of postscript, so this is probably a
> really naive question, but I'm having difficulties with getting my
> postscript plots to be in colour. An extract of my code is below:
>
> =====
> device, decomposed=0 ;specify I'm using Indexed Colors
> loadcolors ;loads graphics colors
[snip]
> entry_device = !d.name
> set_plot, 'PS'
> device, /color, /landscape, font_size=12, filename='FullScatterPlot' +
> STRTRIM(N, 1) + 'runs.ps'
I don't know the side effects of changing the graphics device, so
I usually use the following setup in a fixed sequence.
1st set_plot ; select device
2nd device, decomposed=0, /color, .... ; set device properties
3rd ... more device options ; set page properties
4th loadcolors ; set color for next page
5th ... more setup ; more setup for page
6th ... setup for first plot
HTH
Norbert
|
|
|
Re: Using Postscript & Colours in IDL [message #58414 is a reply to message #58324] |
Mon, 28 January 2008 08:11  |
liamgumley
Messages: 74 Registered: June 2005
|
Member |
|
|
On Jan 28, 9:10 am, chloesharro...@gmail.com wrote:
> Sorry, I know I'm being really slow/annoying, but I'm still completely
> lost! I have tried using Liam Gumley's book (I have it in front of me
> as I type), but am still completely lost with using colours in
> postscript output (I can't follow his examples because I don't
> understand the basics - I don't know the difference between an 8-bit
> mode or 24-bit display etc.
Chloé,
I agree that graphics in IDL can be a bit confusing. Here's a simple
example, based on the LOADCOLORS (p. 249), PSON (p. 362), and PSOFF
(p. 366) sample programs from my book. First, download and unzip the
sample program zip file (PIP_programs.zip) from
http://gumley.com/PIP/About_Book.html
Start a new IDL session, and then change to the directory where you
unzipped the sample programs, e.g.,
IDL> cd, '/home/chloe/PIP_programs'
Then try this example program which first renders a multi-color plot
onscreen, and then sends the same plot to a PostScript output file
named test.ps.
;===
PRO TEST_PLOT
x = [0, 1, 2, 3, 4]
y = [0, 2, 4, 6, 8]
;- Create the plot onscreen
loadcolors
plot, x, y, title='My Test Plot', background=7, color=0, /nodata
oplot, x, y * 1.00, psym=4, symsize=2, color=4
oplot, x, y * 0.50, psym=5, symsize=2, color=5
oplot, x, y * 0.25, psym=6, symsize=2, color=6
;- Repeat the plot to PostScript output
loadcolors
pson, filename='test.ps'
plot, x, y, title='My Test Plot', background=7, color=0, /nodata
oplot, x, y * 1.00, psym=4, symsize=2, color=4
oplot, x, y * 0.50, psym=5, symsize=2, color=5
oplot, x, y * 0.25, psym=6, symsize=2, color=6
psoff
END
;===
Note that the PSON and PSOFF routines make it easy to switch on and
switch off the PostScript device. If you want to add the sample
program directory to your IDL path so that PSON and PSOFF are always
available, regardless of which directory you are in when you start
IDL, then create an IDL startup file as explained on p. 204. My IDL
startup file looks like this:
if !version.os_family eq 'unix' then device, true_color=24
window, /free, /pixmap, colors=-10
wdelete, !d.window
device, decomposed=0, retain=2, set_character_size=[10, 12]
device, get_visual_depth=depth
compile_opt idl2
!path = !path + ':/home/gumley/idl/PIP_programs'
print, 'Display depth: ', strcompress(depth)
print, 'Color table size: ', strcompress(!d.table_size)
print, 'Default integer type: ', size(0, /tname)
journal
Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
|
|
|
Re: Using Postscript & Colours in IDL [message #58421 is a reply to message #58324] |
Mon, 28 January 2008 07:16  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
chloesharrocks@gmail.com writes:
> However, I keep getting an error message when I try to compile - it
> says there's a syntax error on the line beginning "keywords". I'm so
> confused! Is this trying to configure the postscript device! Sorry
> again for asking questions that must seem very naive, but to someone
> who doesn't have a clue what they're doing they're just questions
> desperately trying to understand something very simple!
Well, here is a silly question in return. Did you unzip
the zip file and extract the contents?
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.")
|
|
|