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

Home » Public Forums » archive » Re: Color Fonts?!?!?
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: Color Fonts?!?!? [message #30288] Wed, 17 April 2002 14:18 Go to next message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"David Fanning" <david@dfanning.com> wrote in message
news:MPG.17277a828a98a634989891@news.frii.com...
> David Fanning (david@dfanning.com) writes:
>
>> This really is impossible in IDL without (a slim possibility,
>> really) some Herculean effort and extraordinary hacking. I
>> seriously doubt it is worth the trouble.
>
> Well, having said this, I guess it took me about 5 minutes to knock
> it out. :-)

Oh come on, David! Do you think we're going to be fooled by an old
trick like that? You came up with the solution *before* you said it
was impossible. But be warned: with Google Groups you'll be caught out
the next time you try to recycle this trick.

Oops, I nearly forgot the smiley :-)

--
Mark Hadfield
m.hadfield@niwa.co.nz Ka puwaha et tai nei
http://katipo.niwa.co.nz/~hadfield Hoea tatou
National Institute for Water and Atmospheric Research (NIWA)
Re: Color Fonts?!?!? [message #30292 is a reply to message #30288] Wed, 17 April 2002 13:34 Go to previous messageGo to next message
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
On Wed, 17 Apr 2002, David Fanning wrote:
> Ken Mankoff (mankoff@I.HATE.SPAM.cs.colorado.edu) writes:
>> I agree that this currently works best for a simple hard-coded
>> journal-article type plot, but I think that this is still even easier
>> than you think it is.
> Maybe. But I'm with you, I'm going to rely on Sean to
> work it out and let us know. Monochrome has always been
> good enough for me. :-)

I second that motion.
Sean: please implement algorithm and post when done :)

-k.
--
------------------------------------------------------------ ---------------
Ken Mankoff http://lasp.colorado.edu/snoe/
http://lasp.colorado.edu/mars/
http://lasp.colorado.edu/~mankoff/ http://lasp.colorado.edu/marsrobot/
------------------------------------------------------------ ---------------
Re: Color Fonts?!?!? [message #30293 is a reply to message #30292] Wed, 17 April 2002 13:40 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ken Mankoff (mankoff@I.HATE.SPAM.cs.colorado.edu) writes:

> I agree that this currently works best for a simple hard-coded
> journal-article type plot, but I think that this is still even easier
> than you think it is.

Maybe. But I'm with you, I'm going to rely on Sean to
work it out and let us know. Monochrome has always been
good enough for me. :-)

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Color Fonts?!?!? [message #30294 is a reply to message #30292] Wed, 17 April 2002 13:23 Go to previous messageGo to next message
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
On Wed, 17 Apr 2002, David Fanning wrote:
> Ken Mankoff (mankoff@I.HATE.SPAM.cs.colorado.edu) writes:
>
>> The steps to make it automatic are just that the user passes in the
>> title and the substring, and the program splits the title on the
>> substring, and then makes the 3 XYOUTS with the dynamically generated
>> substrings.
>
> Well, sorta. Assuming there are three words, you don't
> necessarily want to have them centered on the plot, etc., etc.
>
> But nice work, though. It really was easier than I thought it would
> be to come up with a one-off. That's not too bad if you need it for
> a journal article. And if you had a well-enough defined environment,
> you could even make it semi-automatic with minimal effort.

I agree that this currently works best for a simple hard-coded
journal-article type plot, but I think that this is still even easier
than you think it is. I do believe this could be a full-featured
program that handles 95% of your average PLOT and SURFACE calls, with
far less work than Hercules, Atlas, or Samson ever did. But no, I will
not write it as I have no need for this, outside of a few simple
hard-coded journal-article type plots. :)

1) There is no limitation of 3. You can pass in an array of
substrings, and an optional associated array of colors you want them,
and break the title into n substrings. The only requirement here is
that each substring matches only one regexp. But most titles do not
repeat words, so this should work.

2) You can center XYOUTS perfectly via this method: Write once
offscreen ("XYOUTS, 10, 10, /norm, title, width=w") to get the length
of the entire string (or write twice on-screen, the 2nd time in the
background color to erase it). Knowing the length of the string, and
!position, and CONVERT_COORD will allow you to make an XYOUTS
indistinguishable from an "XTITLE=" keyword to plot

3) If you then use CONVERT_COORD to work in data coordinates, I think
you could even get colors working for words in a 3D PLOT or SURFACE,
where your axes are skewed, using /T3D with XYOUTS.

-k.
--
------------------------------------------------------------ ---------------
Ken Mankoff http://lasp.colorado.edu/snoe/
http://lasp.colorado.edu/mars/
http://lasp.colorado.edu/~mankoff/ http://lasp.colorado.edu/marsrobot/
------------------------------------------------------------ ---------------
Re: Color Fonts?!?!? [message #30295 is a reply to message #30294] Wed, 17 April 2002 13:12 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ken Mankoff (mankoff@I.HATE.SPAM.cs.colorado.edu) writes:

> The steps to make it automatic are just that the user passes in the
> title and the substring, and the program splits the title on the
> substring, and then makes the 3 XYOUTS with the dynamically generated
> substrings.

Well, sorta. Assuming there are three words, you don't
necessarily want to have them centered on the plot, etc., etc.

But nice work, though. It really was easier than I
thought it would be to come up with a one-off. That's
not too bad if you need it for a journal article.
And if you had a well-enough defined environment, you
could even make it semi-automatic with minimal
effort.

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Color Fonts?!?!? [message #30296 is a reply to message #30295] Wed, 17 April 2002 12:46 Go to previous messageGo to next message
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
> Date: Wed, 17 Apr 2002 13:27:18 -0600
> From: David Fanning <david@dfanning.com>
>> This really is impossible in IDL without (a slim possibility, really)
>> some Herculean effort and extraordinary hacking. I seriously doubt
>> it is worth the trouble.
> P.S. Let's just say it would probably take a Herculean
> effort to do it *automatically*. :-)

loadct, 39
data = indgen(10)
title0 = 'This is an ' & title1 = 'extraordinary' & title2 = ' title
erase & plot, data, chars=2
xyouts, 0.3, 0.03, /norm, align=0.0, $
title0, $
chars=2, width=w0
xyouts, 0.3+w0, 0.03, /norm, align=0.0, $
title1, color=254, $
chars=2, width=w1
xyouts, 0.3+w0+w1, 0.03, /norm, align=0.0, $
title2, $
chars=2,

The steps to make it automatic are just that the user passes in the
title and the substring, and the program splits the title on the
substring, and then makes the 3 XYOUTS with the dynamically generated
substrings.

-k.
--
------------------------------------------------------------ ---------------
Ken Mankoff http://lasp.colorado.edu/snoe/
http://lasp.colorado.edu/mars/
http://lasp.colorado.edu/~mankoff/ http://lasp.colorado.edu/marsrobot/
------------------------------------------------------------ ---------------
Re: Color Fonts?!?!? [message #30298 is a reply to message #30296] Wed, 17 April 2002 12:27 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning (david@dfanning.com) writes:

> This really is impossible in IDL without (a slim possibility, really)
> some Herculean effort and extraordinary hacking. I seriously doubt
> it is worth the trouble.

Well, having said this, I guess it took me about 5 minutes
to knock it out. :-)

You can see an example of the plot here:

http://www.dfanning.com/misc/mpi_plot.jpg

I used an iterative process, whereby I used MPI_PLOT
to create a title with a gap in it, and a little program
I cooked up in about 3 minutes to allow me to place
a word on the plot interactively with the mouse. The
program is called PlaceText.

Here are the programs you need:

http://www.dfanning.com/misc/placetext.pro
http://www.dfanning.com/programs/mpi_plot.zip

Cheers,

David

P.S. Let's just say it would probably take a Herculean
effort to do it *automatically*. :-)

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Color Fonts?!?!? [message #30299 is a reply to message #30298] Wed, 17 April 2002 12:13 Go to previous messageGo to next message
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
> Date: Wed, 17 Apr 2002 12:26:45 -0600
> From: Sean Davis <sdavis@nis.lanl.gov>
> Does anyone know how to make a string have different colored fonts. I
> would like the x-axis title on a plot to have a string that has different
> colors. thanks!

OK, after re-reading your post, it seems like you really do want each
letter to be a different color in the same string (weird!). In order
to do this via the method I showed in my last post, you need to use
fixed-width fonts OR somehow get plot to accept an "ALIGN=0.0" call.
If you can do either of these, it is simple to adapt the code below to
a loop of PLOT calls, with xtitle= being the key part.

If you want to do it in your normal font, you have to use XYOUTS, and
position the string in the correct location yourself. But here is how
to get a rainbow string:

data = indgen(10)
title = 'This is a Title'
plot, data
for i=15, 0, -1 do $
xyouts, 0.5, 0.5, align=0.0, /norm, $
strmid(title,0,i)+strmid(' ',i,15), $
color=255-(i*12), chars=2

This is getting closer to the "extraordinary hack" that David
mentioned (as in "extraordinary ugly").

-k.
--
------------------------------------------------------------ ---------------
Ken Mankoff http://lasp.colorado.edu/snoe/
http://lasp.colorado.edu/mars/
http://lasp.colorado.edu/~mankoff/ http://lasp.colorado.edu/marsrobot/
------------------------------------------------------------ ---------------
Re: Color Fonts?!?!? [message #30301 is a reply to message #30299] Wed, 17 April 2002 11:42 Go to previous messageGo to next message
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
> Date: Wed, 17 Apr 2002 12:26:45 -0600
> From: Sean Davis <sdavis@nis.lanl.gov>
> Does anyone know how to make a string have different colored fonts. I
> would like the x-axis title on a plot to have a string that has different
> colors. thanks!

I do this via multiple calls to plot, and using the /NODATA and
/NOERASE keywords. Note that each call should "build" on the previous
ones (ex: remove a "chars=2" from a later call, and it will not work)

loadct, 39
data = indgen(10)
plot, data, /nodata, color=253, xtitle='foo', chars=2
plot, data, /nodata, color=100, xticklen=1, yticklen=1, /noerase, chars=2
plot, data, /noerase, chars=2, psym=-2

I have never made color axis titles until now, but use this method all
the time to put light-gray grids behind my plots (I have one index of
my colortables set to [120,120,120]). It lets you read off the data
more accurately (without using a ruler), but is non-intrusive to the
eye. I think you could even get each letter of your title to be
different, except that it might require a FOR loop (oh no!)

-k.

--
------------------------------------------------------------ ---------------
Ken Mankoff http://lasp.colorado.edu/snoe/
http://lasp.colorado.edu/mars/
http://lasp.colorado.edu/~mankoff/ http://lasp.colorado.edu/marsrobot/
------------------------------------------------------------ ---------------
Re: Color Fonts?!?!? [message #30302 is a reply to message #30301] Wed, 17 April 2002 11:46 Go to previous messageGo to next message
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
> Date: Wed, 17 Apr 2002 12:43:35 -0600
> From: David Fanning <david@dfanning.com>
>
> This really is impossible in IDL without (a slim possibility, really)
> some Herculean effort and extraordinary hacking. I seriously doubt
> it is worth the trouble.

So I don't know anything about Hercules, except that I confuse him
with Samson (strong guy with hair), and Atlas (strong guy with globe).
Tell me about him. :) I work with Mars and Earth globes all day long.

-k.

--
------------------------------------------------------------ ---------------
Ken Mankoff http://lasp.colorado.edu/snoe/
http://lasp.colorado.edu/mars/
http://lasp.colorado.edu/~mankoff/ http://lasp.colorado.edu/marsrobot/
------------------------------------------------------------ ---------------
Re: Color Fonts?!?!? [message #30303 is a reply to message #30301] Wed, 17 April 2002 11:43 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Sean Davis (sdavis@nis.lanl.gov) writes:

> Does anyone know how to make a string have different colored fonts. I
> would like the x-axis title on a plot to have a string that has different
> colors.

This really is impossible in IDL without (a slim possibility, really)
some Herculean effort and extraordinary hacking. I seriously doubt
it is worth the trouble.

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Color Fonts?!?!? [message #30354 is a reply to message #30294] Thu, 18 April 2002 11:32 Go to previous messageGo to next message
Sdavis is currently offline  Sdavis
Messages: 12
Registered: July 1998
Junior Member
On Wed, 17 Apr 2002, Ken Mankoff wrote:

>
> On Wed, 17 Apr 2002, David Fanning wrote:
>> Ken Mankoff (mankoff@I.HATE.SPAM.cs.colorado.edu) writes:
>>
>>> The steps to make it automatic are just that the user passes in the
>>> title and the substring, and the program splits the title on the
>>> substring, and then makes the 3 XYOUTS with the dynamically generated
>>> substrings.
>>
>> Well, sorta. Assuming there are three words, you don't
>> necessarily want to have them centered on the plot, etc., etc.
>>
>> But nice work, though. It really was easier than I thought it would
>> be to come up with a one-off. That's not too bad if you need it for
>> a journal article. And if you had a well-enough defined environment,
>> you could even make it semi-automatic with minimal effort.
>
> I agree that this currently works best for a simple hard-coded
> journal-article type plot, but I think that this is still even easier
> than you think it is. I do believe this could be a full-featured
> program that handles 95% of your average PLOT and SURFACE calls, with
> far less work than Hercules, Atlas, or Samson ever did. But no, I will
> not write it as I have no need for this, outside of a few simple
> hard-coded journal-article type plots. :)
>
> 1) There is no limitation of 3. You can pass in an array of
> substrings, and an optional associated array of colors you want them,
> and break the title into n substrings. The only requirement here is
> that each substring matches only one regexp. But most titles do not
> repeat words, so this should work.
>
> 2) You can center XYOUTS perfectly via this method: Write once
> offscreen ("XYOUTS, 10, 10, /norm, title, width=w") to get the length
> of the entire string (or write twice on-screen, the 2nd time in the
> background color to erase it). Knowing the length of the string, and
> !position, and CONVERT_COORD will allow you to make an XYOUTS
> indistinguishable from an "XTITLE=" keyword to plot

I'm not sure I understand how to find where the XTITLE would have been
placed on the plot, in the monochrome case. If you knew where the XTITLE
would have been placed, then it seems that using XYOUTS would work great.

For example, the monochrome case would be

PLOT, findgen(20), xtitle = 'This is a cool title'

It seems to me you're saying that if I wanted the word 'cool' to be blue,
I could do the following:

1. PLOT, findgen(20)

2. Break the title string into 3 strings

3. Make 3 calls to XYOUTS

So my question is, how would I know the correct positions to send to
XYOUTS so that the xtitle appears in the same place as it would as if I
had just called

PLOT, findgen(20), xtitle='this is a cool title'

???


-Sean


>
> 3) If you then use CONVERT_COORD to work in data coordinates, I think
> you could even get colors working for words in a 3D PLOT or SURFACE,
> where your axes are skewed, using /T3D with XYOUTS.
>
> -k.
> --
> ------------------------------------------------------------ ---------------
> Ken Mankoff http://lasp.colorado.edu/snoe/
> http://lasp.colorado.edu/mars/
> http://lasp.colorado.edu/~mankoff/ http://lasp.colorado.edu/marsrobot/
> ------------------------------------------------------------ ---------------
>
>
Re: Color Fonts?!?!? [message #30452 is a reply to message #30288] Tue, 23 April 2002 09:55 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
This is all to complicated

for example

tek_color
text=['Dies',' ist',' ein',' Test']
xyouts,0.5,0.5,text,color=[0,5,2,3,4]

You need as much blanks as letters for each word.
This could be done by strlen.


regards
Reimar




Mark Hadfield wrote:
>
> "David Fanning" <david@dfanning.com> wrote in message
> news:MPG.17277a828a98a634989891@news.frii.com...
>> David Fanning (david@dfanning.com) writes:
>>
>>> This really is impossible in IDL without (a slim possibility,
>>> really) some Herculean effort and extraordinary hacking. I
>>> seriously doubt it is worth the trouble.
>>
>> Well, having said this, I guess it took me about 5 minutes to knock
>> it out. :-)
>
> Oh come on, David! Do you think we're going to be fooled by an old
> trick like that? You came up with the solution *before* you said it
> was impossible. But be warned: with Google Groups you'll be caught out
> the next time you try to recycle this trick.
>
> Oops, I nearly forgot the smiley :-)
>
> --
> Mark Hadfield
> m.hadfield@niwa.co.nz Ka puwaha et tai nei
> http://katipo.niwa.co.nz/~hadfield Hoea tatou
> National Institute for Water and Atmospheric Research (NIWA)

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Help me aviod a FOR loop!?!?
Next Topic: 24-bit color problem on Red Hat Linux 7.1

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

Current Time: Wed Oct 08 17:08:47 PDT 2025

Total time taken to generate the page: 0.00897 seconds