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

Home » Public Forums » archive » Re: Barplot using Coyote, the colors keep changing, why?
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: Barplot using Coyote, the colors keep changing, why? [message #86693] Thu, 28 November 2013 07:06 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Galaxytraveler writes:

>
> I have been trying create barplots. I use Coyotes cgBarplot and cgDisplay following the examples found here:
> http://www.idlcoyote.com/cg_tips/barplot.php
>
> And it is working well, however the x-axis color and the barnames keep changing color every time I run the program (even without a new compile) as if it randomly chose which of the graphs now change colors. I can't figure out why. Most often they are white, which means that they invisible, and I can just see them as a white line for the tick.
>
> I have put in AXISCOLOR='black', and it makes the axis turn black just not the x-axis and barname. Do anyone know of a way for forcing the program to use my chosen color? Or know of a smarter way of making barplots?
> (I am using a mac, if that could have any effect on the problem)
>
> A second question is that I would like to save the image afterwards, and have tried to use output='file.png'or ps or jpeg, but I just get the error everytime:
> "CGBARPLOT --> Tag name TT_FONT_OLD is undefined for structure FSC_PS_SETUP.
> Any solutions to why this is or of a different way of doing it?
>
>
> My programming looks like this:
>
> cgDisplay, 1300, 900, WID=0
>
> barnames = ['0.05', '0.15', '0.25', '0.35', '0.45', '0.55', '0.65', '0.75', '0.85', '0.95']
>
> !P.Multi = [0,2,2]
>
> cgBarplot, C, YRange=[0,30],COLORs='red',AXISCOLOR='black', charsize=3., BARNAMES=barnames, BACKGROUND='White',output='file.png'
>
> cgBarPlot, D, YRange=[0,30], Colors='dark green',AXISCOLOR='black', charsize=3., BARNAMES=barnames
>
> cgBarPlot, X, YRange=[0,30], Colors='gold',AXISCOLOR='black', charsize=3., BARNAMES=barnames
>
> cgBarPlot, E, YRange=[0,30], Colors='blue',AXISCOLOR='black', charsize=3., BARNAMES=barnames
>
>
> !P.Multi = 0

Well, you are doing it "All wrong!", as they say. :-)

First of all, follow the directions here to update your Coyote Library
and make sure you have ONE Coyote Library on your path. You have old
programs that are causing you grief.

http://www.idlcoyote.com/code_tips/fixcoyoteprogram.php

Then, forget the AXISCOLOR, BACKGROUND, and OUTPUT keywords. You dont
need them. I don't think you will even need the CHARSIZE keywords, since
Coyote Graphics routines compensate for PostScript output.

Here is how I would write the program.

;----------------------------------------------------------- ------------
PRO Example, PS=ps
seed = -5L
c = RandomU(seed, 10) * 10.0
d = RandomU(seed, 10) * 7.5
x = RandomU(seed, 10) * 7.5
e = RandomU(seed, 10) * 10.0

; Need PostScript output?
IF Keyword_Set(ps) THEN cgPS_Open, 'file.ps'

; Select a character size.
charsize = !P.Charsize
!P.Charsize = (!D.Name EQ 'PS') ? 0.75 : cgDefCharsize()

cgDisplay, 1300, 900, WID=0
names = ['0.05', '0.15', '0.25', '0.35', '0.45', $
'0.55', '0.65', '0.75', '0.85', '0.95']
!P.Multi = [0,2,2]
cgBarplot, C, YRange=[0,30],COLORs='red',BARNAMES=names
cgBarPlot, D, YRange=[0,30], Colors='dark green',BARNAMES=names
cgBarPlot, X, YRange=[0,30], Colors='gold', BARNAMES=names
cgBarPlot, E, YRange=[0,30], Colors='blue', BARNAMES=names
IF Keyword_Set(ps) THEN cgPS_Close, /PNG

; Clean up.
!P.Multi = 0
!P.Charsize = charsize
END
;----------------------------------------------------------- ------------


Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Barplot using Coyote, the colors keep changing, why? [message #86708 is a reply to message #86693] Fri, 29 November 2013 03:30 Go to previous messageGo to next message
galaxytraveler42 is currently offline  galaxytraveler42
Messages: 5
Registered: October 2013
Junior Member
Thanks David for looking into and for even writing a program.

I have been trying to do all you suggested (working on it for 7-9 hours now), and are hoping you have one more advice.

I first downloading your newest library, then delete all older versions. Then I copied your program into a new file and tried to run it. Nice graphs shows up but no file.ps was however created where it was suppose to or anywhere on my computer. I then installed ghostscript and then the imagemagick. I got the path to the 'convert' file into the idl path. Restarting IDL after each step to be sure.

But your program still didn't create the file. I then tried change the program, so that it wasn't waiting the the PS keyword:
;IF Keyword_Set(ps) THEN cgPS_Open, 'file.ps'
cgPS_Open, 'file.ps'
and
;IF Keyword_Set(ps) THEN cgPS_Close, /PNG
cgPS_Close, /PNG

An error then comes up that states "cgPS_Close: ImageMagick must be installed to complete raster operation". after clicking ok, it doesn't show the graph in the display, BUT the file.ps is created with the graph!
However all the text is extremely small and of bad readable. So maybe something still isn't working as it should.

When I try:
print,cgHasImageMagick()
I get '0'.

Any ideas?
Re: Barplot using Coyote, the colors keep changing, why? [message #86709 is a reply to message #86708] Fri, 29 November 2013 05:47 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Galaxytraveler writes:

>
> Thanks David for looking into and for even writing a program.
>
> I have been trying to do all you suggested (working on it for 7-9 hours now), and are hoping you have one more advice.
>
> I first downloading your newest library, then delete all older versions. Then I copied your program into a new file and tried to run it. Nice graphs shows up but no file.ps was however created where it was suppose to or anywhere on my computer. I then installed ghostscript and then the imagemagick. I got the path to the 'convert' file into the idl path. Restarting IDL after each step to be sure.
>
> But your program still didn't create the file. I then tried change the program, so that it wasn't waiting the the PS keyword:
> ;IF Keyword_Set(ps) THEN cgPS_Open, 'file.ps'
> cgPS_Open, 'file.ps'
> and
> ;IF Keyword_Set(ps) THEN cgPS_Close, /PNG
> cgPS_Close, /PNG

There is a PS keyword on the program. To make a PostScript file you type
this:

IDL> Example, /PS

Otherwise, the output goes to the display.


> An error then comes up that states "cgPS_Close: ImageMagick must be installed to complete raster operation". after clicking ok, it doesn't show the graph in the display, BUT the file.ps is created with the graph!
> However all the text is extremely small and of bad readable. So maybe something still isn't working as it should.

> Any ideas?

Well, I'm guessing a Mac. That causes many a problem with getting
ImageMagick installed properly. Here is an article that explains the
problem:

http://www.idlcoyote.com/cg_tips/findimonmac.php

I've no idea why the text is extremely small in the PostScript file.
But, I did notice in your original code that you had the font size so
large than it nearly took over the page when I ran your code. So maybe
something is radically different with our two machines with regard to
fonts. In any case, adjusting the font size in the program will help.
:-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: black wrong multicolor map
Next Topic: Variable Pixel Spacing for Images in IDL

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

Current Time: Wed Oct 08 13:43:22 PDT 2025

Total time taken to generate the page: 0.00720 seconds