Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • coefplot and axis labels of different colors

    Hi all!

    I am using coefplot to plot predicted probabilities at certain values for 5 model specifications x 4 subgroups.

    Each predicted probability and the corresponding CI is of a certain color that matches the group for which the batch of models was estimated.

    Is there a way to make the color of the label text for each group match the color used for the estimates (marker and CI spikes)?

    In this specific case, make the Turkish label "cranberry", Moroccan "olive" and Pakistani "navy".

    Based on the graph editor it does seem to have to do with tick labels, but would like to implement this via code rather than editor

    Code:
    // File created by Graph Editor Recorder.
    // Edit only if you know what you are doing.
    
    .yaxis1.major.num_rule_ticks = 0
    .yaxis1.edit_tick 3 3 `"Moroccan"', custom tickset(major) editstyle(tickstyle(textstyle(color(olive))) )
    // yaxis1 edits
    Many thanks in advance,
    Natalia

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	78.1 KB
ID:	1646756
    Last edited by natalia malancu; 25 Jan 2022, 18:00.

  • #2
    coefplot is from SSC, as you are asked to explain (FAQ Advice #12). I don't think that you can do it with -ylabel()- as it affects the rendition of the entire axis labels. You can use the undocumented command gr_edit to run code retrieved from the graph editor. After running the coefplot command:

    Code:
    local colors black cranberry olive navy
    local group Yugoslavs Turkish Moroccan Pakistani
    forval i=2/ `=wordcount("`colors'")'{
        gr_edit .yaxis1.major.num_rule_ticks = 0
        gr_edit .yaxis1.edit_tick `i' `i' "`=word("`group'", `i')'", custom tickset(major) editstyle(tickstyle(textstyle(color("`=word("`colors'", `i')'"))) )
        local ++i
    }
    Last edited by Andrew Musau; 26 Jan 2022, 05:09.

    Comment

    Working...
    X