Announcement

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

  • scatter plot with individual-specific markers and color varying by group

    I have data on firms making decisions week to week. I want to plot "who" makes a decision first in each week. However, firms have some common characteristics that allow me to classify them into groups. Therefore, I want the marker to be firm specific but the color of the marker to be common to all firms in a group. This will allow me to i) see which groups are more likely to be the first to make a decision, and ii) which firms are more likely to be the first ones to make a decision. I also want the label to be define by group, not by firm. Finally, if possible, I would like this to be done automatically rather than by hand as it has to be done many times and the groups may vary by case (and the firms will certainly be different from case to case).

    Thanks.

  • #2
    Please read and act on

    http://www.statalist.org/forums/help#realnames

    http://www.statalist.org/forums/help#stata

    Otherwise we're expected to read your post, understand and imagine your data structure, invent variable names, etc., even before we can suggest syntax.

    Instead

    Code:
    help scatter
    is the most suitable answer until you provide good detail.

    Comment


    • #3
      Nick, thanks for the message. I asked for the name to be changed. Regarding the question: the data looks as follows
      Code:
      clear
      inp   week firmid brand price 
      1 5 2 2
      2 5 2 1.5
      3 5 2 3
      4 2 2 2.5
      5 2 2 2
      6 3 1 5
      7 3 1 4
      8 5 2 5
      9 4 1 5
      10 4 1 4
      end
      This is, for each week, the data records the firm that first changed its price. I need to plot prices over time, with each point representing at the same time firmid and brand. I would like the color to vary by brand (so firms 2 and 5 would share a color and firms 3 and 4 would share a different one), but markers to be firm specific. Also, there are many firms and several brands so I would like this to be automatized.

      Comment


      • #4
        Thanks for the example. Here's some technique. Fully automated code for arbitrary firm-brand combinations is too open a problem for me to solve. I'd counsel that separating more than about 7 groups is usually a recipe for a mess.

        Code:
        separate price, by(firm) veryshortlabel
        
        twoway connected price? week, ms(Oh X Dh Th) mc(red blue blue red)  ytitle(price)
        You'd need to think about line colours too if you wanted lines at all.

        Comment


        • #5
          Thanks Nick. I'll need to work on automated code as this has to be done (independently) for different regions that have a different number of firms and brands. This means that I won't know how many firms and brands I need to put in ms() and mc() without actually looking at each region one at a time.

          Comment

          Working...
          X