Re: Barplot using Coyote, the colors keep changing, why? [message #86693] |
Thu, 28 November 2013 07:06  |
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.")
|
|
|