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

Home » Public Forums » archive » Using Postscript & Colours in IDL
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
Using Postscript & Colours in IDL [message #58335] Mon, 28 January 2008 01:47 Go to next message
chloesharrocks is currently offline  chloesharrocks
Messages: 16
Registered: January 2008
Junior Member
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

;If we also want to consider a specific period of time
;Here we will look at scatter plot for first 5years only
j = 0 ;Here we specify which measurement in time, eg. the first one

entry_device = !d.name
set_plot, 'PS'
device, /color, /landscape, font_size=12, filename='FullScatterPlot' +
STRTRIM(N, 1) + 'runs.ps'
!P.Multi=0
plot, temp_change, precip_change, xrange=[-2,8], yrange=[-3E-6, 5E-6],
xstyle=1, ystyle=1, $
title='A Scatter Plot of Precipitation Against Temperature for Years
0-5 for ' + STRTRIM(N, 1) + ' Runs', $
;subtitle='Green Diamonds=0-5years, Red Triangles=5-10years & Blue
Squares=10-15years', $
xtitle='Global Mean Surface Air Temperature Change (Kelvin)', $
ytitle='Global Mean Precipitation Change (Kg/[m^2*s])', /nodata,
background=7, color=0
oplot, temp_change[j:j+19,run_no:run_no+(N-1)], precip_change[j:j
+19,run_no:run_no+(N-1)], psym=4, color=4
oplot, temp_change[j+20:j+39,run_no:run_no+(N-1)], precip_change[j
+20:j+39,run_no:run_no+(N-1)], psym=5, color=5
oplot, temp_change[j+40:j+59,run_no:run_no+(N-1)], precip_change[j
+40:j+59,run_no:run_no+(N-1)], psym=6, color=6
device, /close_file
set_plot, entry_device
=====

Most of the time this works fine, but occaisionally when I run the
program it comes up with an error on the "device, decomposed=0" line.
However, if I shut down IDL and restart it it will work fine again.
Also, although "color=4" looks lime green on my computer, when I print
it, the colour is more of a bluey-turquoise colour and similarly the
"color=5" 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).

Thanks
Chloé
Re: Using Postscript & Colours in IDL [message #58389 is a reply to message #58335] Mon, 28 January 2008 14:44 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
David Fanning wrote:
> Paul van Delst writes:
>
>> Regarding font sizing, I have never used font_size. I always use the charsize keyword to
>> the relevant graphics command. And for the x/ps switch, I typically have something like
>> the following in most of my plotting codes:
>>
>> charsize = (!D.NAME eq 'PS') ? 1.25 : 1.5 ; Adjust as appropriate
>> font = (!D.NAME eq 'PS') ? 1 : -1
>> thick = (!D.NAME eq 'PS') ? 2 : 1
>
> Well, good luck. I'm going to let you answer the
> rest of her questions. :-)

I guess I'm just not a gui-type of guy. :o)

cheers,

paulv
Re: Using Postscript & Colours in IDL [message #58393 is a reply to message #58335] Mon, 28 January 2008 14:27 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paul van Delst writes:

> Regarding font sizing, I have never used font_size. I always use the charsize keyword to
> the relevant graphics command. And for the x/ps switch, I typically have something like
> the following in most of my plotting codes:
>
> charsize = (!D.NAME eq 'PS') ? 1.25 : 1.5 ; Adjust as appropriate
> font = (!D.NAME eq 'PS') ? 1 : -1
> thick = (!D.NAME eq 'PS') ? 2 : 1

Well, good luck. I'm going to let you answer the
rest of her questions. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Using Postscript & Colours in IDL [message #58395 is a reply to message #58335] Mon, 28 January 2008 13:56 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
liamgumley@gmail.com wrote:
> On Jan 28, 10:50 am, chloesharro...@gmail.com wrote:
>> Hi Liam
>>
>> Thanks very much for that - so much more novice-friendly and I already
>> had the zip file downloaded and extracted in my IDL path so I could
>> use them instantly. I've now used pson and psoff to run one of my
>> graphs and it worked fine, so that's great! This is probably a silly
>> question, but if I wanted to use the usual method for sending stuff to
>> postscript (ie not pson/posff), can I just call "loadcolors" but not
>> specify 'device, decomposed=0'? The reason I ask is I have several
>> plots within different codes all set up like this and it would be
>> easier to delete that one line, than change the code. If not, that's
>> fine - I'll stick with this as it works!
>>
>> One thing I've noticed however, is that with pson I can't change the
>> font size (using font_size) and I presume there are some other
>> limitations to using pson too.
>>
>> Thanks ever so much for your help Liam - that really is much simpler
>> for someone like me to use! I only have a couple of weeks to grasp
>> enough IDL to analyse my data for my research project and sadly don't
>> have the time to get to grips with more sophisticated stuff! Your book
>> has already been invaluable!
>
> Chlo�,
>
> PSON and PSOFF are meant to be drop in replacements for the SET_PLOT
> commands used to select and deselect the PostScript device. They
> include additional intelligence which makes configuring the PostScript
> device much easier than using DEVICE commands. If I was you, I'd
> modify your code to use it.

To the OP,

FWIW, I use pson and psoff exclusively and they have made my life very simple. My plots
now always have the same aspect ratio (might not sound like a big deal, but I like
reproducibility :o)

Regarding font sizing, I have never used font_size. I always use the charsize keyword to
the relevant graphics command. And for the x/ps switch, I typically have something like
the following in most of my plotting codes:

charsize = (!D.NAME eq 'PS') ? 1.25 : 1.5 ; Adjust as appropriate
font = (!D.NAME eq 'PS') ? 1 : -1
thick = (!D.NAME eq 'PS') ? 2 : 1
....
plot, x, y, $
...other keywords...., $
charsize=charsize,font=font,thick=thick

Then, all I do is

pson
myplot_procedure
psoff

and the plots look quite marvyplate whether I'm displaying them onscreen or squirting them
to a ps file.

cheers,

paulv
Re: Using Postscript & Colours in IDL [message #58397 is a reply to message #58335] Mon, 28 January 2008 12:24 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
liamgumley@gmail.com writes:

> PSON and PSOFF are meant to be drop in replacements for the SET_PLOT
> commands used to select and deselect the PostScript device. They
> include additional intelligence which makes configuring the PostScript
> device much easier than using DEVICE commands. If I was you, I'd
> modify your code to use it.

And PSConfig does exactly the same thing in a graphical and
interactive way that is easier for some people to understand
and use. Although, not always. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Using Postscript & Colours in IDL [message #58398 is a reply to message #58335] Mon, 28 January 2008 12:18 Go to previous message
liamgumley is currently offline  liamgumley
Messages: 74
Registered: June 2005
Member
On Jan 28, 10:50 am, chloesharro...@gmail.com wrote:
> Hi Liam
>
> Thanks very much for that - so much more novice-friendly and I already
> had the zip file downloaded and extracted in my IDL path so I could
> use them instantly.  I've now used pson and psoff to run one of my
> graphs and it worked fine, so that's great! This is probably a silly
> question, but if I wanted to use the usual method for sending stuff to
> postscript (ie not pson/posff), can I just call "loadcolors" but not
> specify 'device, decomposed=0'?  The reason I ask is I have several
> plots within different codes all set up like this and it would be
> easier to delete that one line, than change the code.  If not, that's
> fine - I'll stick with this as it works!
>
> One thing I've noticed however, is that with pson I can't change the
> font size (using font_size) and I presume there are some other
> limitations to using pson too.
>
> Thanks ever so much for your help Liam - that really is much simpler
> for someone like me to use! I only have a couple of weeks to grasp
> enough IDL to analyse my data for my research project and sadly don't
> have the time to get to grips with more sophisticated stuff! Your book
> has already been invaluable!

Chloé,

PSON and PSOFF are meant to be drop in replacements for the SET_PLOT
commands used to select and deselect the PostScript device. They
include additional intelligence which makes configuring the PostScript
device much easier than using DEVICE commands. If I was you, I'd
modify your code to use it.

PSON does not impose limitations on the DEVICE commands you can use
after PostScript output has been selected. For example, if you want to
select a Times Roman font

pson
device, set_font='Times Bold', /tt_font ; select a TrueType font
plot, x, y, title='My Test Plot', font=1 ; tell PLOT to use the
TrueType font
psoff

See pages 372 and 373 of my book for more information.

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
Re: Using Postscript & Colours in IDL [message #58410 is a reply to message #58335] Mon, 28 January 2008 08:56 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
chloesharrocks@gmail.com writes:

> I'm trying to get it to run by saving the program, then using the
> compile button followed by the run button within the IDL Development
> Environment (basically the same as typing .compile...etc) but I still
> get an error in the syntax on the line beginning "keyword" when I
> compile it.

Well, I think these programs are still not on your
path. Try exiting IDL, starting it up again, and
then typing this:

IDL> k = psconfig()

If that doesn't work, send us the error message.
If it does work, try your program. Let us know. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Using Postscript & Colours in IDL [message #58411 is a reply to message #58335] Mon, 28 January 2008 08:50 Go to previous message
chloesharrocks is currently offline  chloesharrocks
Messages: 16
Registered: January 2008
Junior Member
Hi Liam

Thanks very much for that - so much more novice-friendly and I already
had the zip file downloaded and extracted in my IDL path so I could
use them instantly. I've now used pson and psoff to run one of my
graphs and it worked fine, so that's great! This is probably a silly
question, but if I wanted to use the usual method for sending stuff to
postscript (ie not pson/posff), can I just call "loadcolors" but not
specify 'device, decomposed=0'? The reason I ask is I have several
plots within different codes all set up like this and it would be
easier to delete that one line, than change the code. If not, that's
fine - I'll stick with this as it works!

One thing I've noticed however, is that with pson I can't change the
font size (using font_size) and I presume there are some other
limitations to using pson too.

Thanks ever so much for your help Liam - that really is much simpler
for someone like me to use! I only have a couple of weeks to grasp
enough IDL to analyse my data for my research project and sadly don't
have the time to get to grips with more sophisticated stuff! Your book
has already been invaluable!

Chloé
Re: Using Postscript & Colours in IDL [message #58417 is a reply to message #58335] Mon, 28 January 2008 07:52 Go to previous message
chloesharrocks is currently offline  chloesharrocks
Messages: 16
Registered: January 2008
Junior Member
Hi

Have corrected filename so program now reads:

=====
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
=====

I'm trying to get it to run by saving the program, then using the
compile button followed by the run button within the IDL Development
Environment (basically the same as typing .compile...etc) but I still
get an error in the syntax on the line beginning "keyword" when I
compile it.

Thanks
Chloé
Re: Using Postscript & Colours in IDL [message #58418 is a reply to message #58335] Mon, 28 January 2008 07:38 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
chloesharrocks@gmail.com writes:

> Yes I have unzipped and extracted all the contents and as far as I can
> tell have successfully added them to the IDL path (I used, preferences-
>> path and then inserted the folder named "color" so that its now in
> the list of the IDL File Search path).
>
> Sadly I can't use excel as I need to analyse 1000s of data sets, but
> at the moment I'm just trying to grasp the basics of IDL, ie. learning
> to plot a simple graph before I move on to more complicated things.

Well, Chloe, I don't see anything wrong with the program. :-)

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

You have mis-spelled the file name. And you are not
using all those wonderful keywords you collected from
PSConfig. But this code should at least run. How are
you going about trying to get it to run? Something like
this should work:

IDL> .compile color_plot
IDL> color_plot

I'll be out of touch for a couple of hours, but this
ought to be really, really simple. The folks here can
help you sort it out. :-)

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 #58419 is a reply to message #58335] Mon, 28 January 2008 07:25 Go to previous message
chloesharrocks is currently offline  chloesharrocks
Messages: 16
Registered: January 2008
Junior Member
Hi

Yes I have unzipped and extracted all the contents and as far as I can
tell have successfully added them to the IDL path (I used, preferences-
> path and then inserted the folder named "color" so that its now in
the list of the IDL File Search path).

Sadly I can't use excel as I need to analyse 1000s of data sets, but
at the moment I'm just trying to grasp the basics of IDL, ie. learning
to plot a simple graph before I move on to more complicated things.

Thanks
Chloé
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: working dir in IDL 7
Next Topic: Re: Simple File I/O

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

Current Time: Wed Oct 08 15:27:02 PDT 2025

Total time taken to generate the page: 0.00793 seconds