Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iegraph : color() has no effect in baroption() option #346

Closed
kbjarkefur opened this issue Aug 8, 2023 · 2 comments
Closed

iegraph : color() has no effect in baroption() option #346

kbjarkefur opened this issue Aug 8, 2023 · 2 comments
Assignees
Labels
minor bug Bug unlikely to lead to incorrect analysis resolved but not yet published Issue is fixed, but not yet published on SSC
Milestone

Comments

@kbjarkefur
Copy link
Contributor

kbjarkefur commented Aug 8, 2023

Issue submitted by email from @oscarmdiazb :

For a while, I've been trying to change the colours of the bars when using the iegraph command, but without success. Would you mind providing an example? I've tried the variations of the following code:

sysuse auto, clear 
reg price foreign 
iegraph foreign,  varlabels legend(pos(6) rows(1)) baroptions(color(green))     barlabel barlabelformat( %9.2f)
@kbjarkefur kbjarkefur self-assigned this Aug 8, 2023
@kbjarkefur
Copy link
Contributor Author

The error reproduces as submitted by user.

The fix was quite straightforward and is implemented in f4ac0a1.

@kbjarkefur kbjarkefur added minor bug Bug unlikely to lead to incorrect analysis resolved but not yet published Issue is fixed, but not yet published on SSC labels Aug 8, 2023
@kbjarkefur
Copy link
Contributor Author

kbjarkefur commented Aug 21, 2023

OP followed up and suggested that baroptions() should be possible to set colors for individual bars. This is not possible using baroptions() as the bar options specified in that option is added to all bars.

Instead, in 0bfb72c a new option barcolors() was added. This option allows the user to manually specify colors, as in barcolors(`" red gs14 "215 25 28" gold cranberry "'). Any color listed in
https://www.stata.com/manuals13/g-4colorstyle.pdf may be used.

Test this option like this:

sysuse auto, clear
replace foreign = floor(runiform()*5)

gen f1 = (foreign == 1)
gen f2 = (foreign == 2)
gen f3 = (foreign == 3)
gen f4 = (foreign == 4)
gen ctrl = (foreign == 5)
 
reg price f1 f2 f3 f4 weight
iegraph f1 f2 f3 f4 , legend(pos(6) rows(1)) barcolors(`" red gs14 "215 25 28" gold cranberry "') barlabel barlabelformat( %9.2f) mlabcolor(blue) 

If barcolors() is used together with baroptions(color(green)) then the later takes precedence, as baroption() has the highest precedence to allow the user to overwrite any options used.

@ankritisingh ankritisingh added this to the v7.3 milestone Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor bug Bug unlikely to lead to incorrect analysis resolved but not yet published Issue is fixed, but not yet published on SSC
Projects
None yet
Development

No branches or pull requests

2 participants