Announcement

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

  • Using valuelabel: labels not displaying on striplot

    I need to offset actual values of variable dev_all_gr on the y axis of a striplot (from ssc), and label them for clarity. I have defined the labels for the points I would like to label as follows:
    Code:
    lab def graph_scale -55 "-50"  -15 "-10"  -10 "-5" -5 "None" 5 "None"  10 "5" 15 "10" 55 "50"  105 "100" 
    lab val dev_all_gr graph_scale
    In the striplot code, I then define these points as those I would like to label, and use the valuelabel command to use the defined labels rather than the actual values:

    Code:
    stripplot dev_all_gr, over(molnum) stack height(0.6) ms(circle circle diamond diamond square square triangle)  vertical yla(, ang(h)) separate(inn_disp) mlcolor(orange purple orange purple orange purple white) mcolor(orange*0.4 purple*0.4 orange*0.4 purple*0.4 orange*0.4 purple*0.4 white) msize(vsmall vsmall vsmall vsmall vsmall vsmall tiny) ///
    ylabel(-55 -15 -10 -5 5 10 15 55 105,labsize(vsmall) valuelabel) ///
    ytitle("Deviation from permitted limits, in percent", size(vsmall) margin(r=2))  ///
    yline(-5 5, lpattern(dash) lcolor(green)) width(2) ///
    xscale(r(0.5 5.5)) xlabel(, valuelabel labsize(vsmall)) xtitle("") ///
    text(1 2 "Notional range of acceptability", color(green) size(tiny)) ///
    legend(order(1 "Failed assay" 3 "Failed dissolution" 5 "Failed assay and dissolution") rows(1) size(vsmall) region(lcolor(gray*.3))) /// 
    note("Orange markers: Branded; Purple markers: Unbranded", size(vsmall)) ///
    plotregion(lstyle(none))
    The valuelabel option on the x axis provides the correct result; however that on the y axis stubbornly insists on giving underlying values rather than labels. Could this possibly be because none of my data points map exactly to the (underlying) labelled values? Is there a way to resolve this? (I tried a workaround with labmask but it does not work because my values are not integers.) Herewith a data extract for replication. Thanks for any help

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(inn_disp dev_all_gr) byte molnum
    1  -5.19 5
    6   -9.7 1
    2  11.53 1
    4 -44.07 1
    4    -54 1
    4 -53.54 1
    4 -49.75 1
    4  -10.8 4
    3  -5.32 5
    1 -12.03 3
    1 -12.85 3
    1  -5.77 3
    1 -11.09 3
    3  -6.08 3
    3  -5.02 3
    4  -5.02 5
    6  -9.55 5
    4  -5.52 5
    6   -8.3 5
    4  -6.38 5
    end
    label values dev_all_gr graph_scale
    label values molnum molnum
    label def molnum 1 "Allopurinol", modify
    label def molnum 3 "Amoxicillin", modify
    label def molnum 4 "Dexamethasone", modify
    label def molnum 5 "Cefixime", modify

  • #2
    You are asking stripplot for different colours, symbols. and so forth, and the only way that's possible is by separating your outcome on the fly into several variables. So, inside the code it's not dev_all_gr that is being plotted at all, but several different temporary variables, and they don't inherit the value labels you defined. Perhaps there's a way of making the code check for such a call to use value labels, but that would be fiddly, and there might be side-effects.

    Meanwhile, there is a much easier work-around which is just to ask directly for the axis label text you want.

    The fact is that none of these labels is a data point is not material here.

    If I've edited the jumbled code correctly, that should be something like.


    Code:
    clear
    input float(inn_disp dev_all_gr) byte molnum
    1  -5.19 5
    6   -9.7 1
    2  11.53 1
    4 -44.07 1
    4    -54 1
    4 -53.54 1
    4 -49.75 1
    4  -10.8 4
    3  -5.32 5
    1 -12.03 3
    1 -12.85 3
    1  -5.77 3
    1 -11.09 3
    3  -6.08 3
    3  -5.02 3
    4  -5.02 5
    6  -9.55 5
    4  -5.52 5
    6   -8.3 5
    4  -6.38 5
    end
    label values dev_all_gr graph_scale
    label values molnum molnum
    label def molnum 1 "Allopurinol", modify
    label def molnum 3 "Amoxicillin", modify
    label def molnum 4 "Dexamethasone", modify
    label def molnum 5 "Cefixime", modify
    
    lab def graph_scale -55 "-50"  -15 "-10"  -10 "-5" -5 "None" 5 "None"  10 "5" 15 "10" 55 "50"  105 "100" 
    lab val dev_all_gr graph_scale
    
    stripplot dev_all_gr, over(molnum) stack height(0.6) ms(circle circle diamond diamond square square triangle)  vertical yla(, ang(h)) separate(inn_disp) mlcolor(orange purple orange purple orange purple white) mcolor(orange*0.4 purple*0.4 orange*0.4 purple*0.4 orange*0.4 purple*0.4 white) msize(vsmall vsmall vsmall vsmall vsmall vsmall tiny) ///
    ylabel( -55 "-50"  -15 "-10"  -10 "-5" -5 "None" 5 "None"  10 "5" 15 "10" 55 "50"  105 "100", labsize(vsmall)) ///
    ytitle("Deviation from permitted limits, in percent", size(vsmall) margin(r=2))  ///
    yline(-5 5, lpattern(dash) lcolor(green)) width(2) ///
    xscale(r(0.5 5.5)) xlabel(, valuelabel labsize(vsmall)) xtitle("") ///
    text(1 2 "Notional range of acceptability", color(green) size(tiny)) ///
    legend(order(1 "Failed assay" 3 "Failed dissolution" 5 "Failed assay and dissolution") rows(1) size(vsmall) region(lcolor(gray*.3))) /// 
    note("Orange markers: Branded; Purple markers: Unbranded", size(vsmall)) ///
    plotregion(lstyle(none))

    Comment


    • #3
      Thank you.

      Comment


      • #4
        I should note that separate itself, which is an official command although first written by me, is careful about copying value labels. But within stripplot what you're asking for also entails binning and stacking to get to the data points that the graph shows, so the value labels get lost along the way.

        Comment

        Working...
        X