Announcement

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

  • stacking two-way -tabplot- bars by a third variable

    Dear list,

    quick question about Nick Cox's -tabplot-
    Code:
    net sj 16-2 gr0066
    Anyone found a way to stack the bars by a third variable? Consider the two-way graphic example below. I'm wondering if there is a way to augment it with information over the composition of each bar, which may be represented by having each bar subdivided in two colors - .e.g. partitioning the same information according to a further binary variable, drawing one plot for each of the two categories, and stacking the bars. To be even more precise, suppose the category "original research" is further divided in 2 subgroups in my dataset. I would like this to show up in the bars above "original research" being stacked accordingly and differentiated in color - rather than splitting the "original research" category in two and having one additional fifth column.

    Apologies in advance for the lack of data. If a way exists and a pointer is given, I'll try to post a summary illustration below.
    Click image for larger version

Name:	research_type_by_geographical_focus2.jpg
Views:	1
Size:	147.4 KB
ID:	1652778




    .
    Last edited by Matteo Pinna Pintor; 03 Mar 2022, 01:27.
    I'm using Stata/MP 17

  • #2
    tabplot is to be considered as from the Stata Journal. It doesn't support stacking at all, as its major premise is that stacking is evil. You would need to write your own code for stacking.

    Comment


    • #3
      Amended package link in #1. Stacking might evil most of the times, but imho here and in analog cases (possibly infrequent) it would fit just fine. Thanks!

      [edit] Uhm ok maybe it would not be perfect though - the number-labeling of bars would become problematic. I'll split one column in two - and fair enough if all columns had to be split one can combine two graphs.
      Last edited by Matteo Pinna Pintor; 03 Mar 2022, 01:34.
      I'm using Stata/MP 17

      Comment


      • #4
        As you say, stacking isn’t consistent with a key option of tabplot that puts text labels under each bar. What you want is programmable within limits but is way beyond what I intend to support. Sorry if that is disappointing.

        Comment


        • #5
          Nah, it's okay - upon reflection I agree with you.

          What might be nice would be a way to have two layers of axis labels (in my case x axis) to emphasize that some columns should be read as a breakdown. So, in my case (see below, ignore formatting issues), just one "original research" label, and the "non-core / core" labels below. This might be doable already perhaps, playing with some label spacing options?

          [edit] there is also no way to color bars differently for different categories using just one categorical variable, correct? Ah ok, there is. Sorry
          Attached Files
          Last edited by Matteo Pinna Pintor; 03 Mar 2022, 02:38.
          I'm using Stata/MP 17

          Comment

          Working...
          X