Announcement

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

  • graph buble with pie charts

    Hello any way on Stata to create a buble graph and each bubble can be dissected into parts like a pie chart?




  • #2
    My guess is no, but it's only a guess.

    So you want a scatterplot with dozens of little, potentially overlapping, variably sized pie charts? If you are sure that your audience will appreciate digesting so much (not strictly related) information in a single graph, then maybe you can create a complex, layered dot chart as an alternative.

    Otherwise, consider multiple separate simpler graphs that present the information in conceptually more bite-sized portions.

    Comment


    • #3
      I know this is an old one... I found a few other posts asking similar questions. Decided this one looked like a good place to show a possible template that solves the bubble chart problem. A student this semester asked me for help. In short, here is a first draft.


      Code:
      // Standard set the environment
      cls
      set more off
      clear all
      
      // Lets demonstrate a 'three-dimensional' visualization
      sysuse auto
      
      // --- This is a 'four-dimensional' with a 'bubble' element
      
      // Create an ordinal based on price
      xtile pbubble = price, nquantiles(3)
      
      // Add a few observations that will support the 'legend'
      set obs 80
      
      // Enter 'legend data'
      replace weight = 4000 in 75
      replace weight = 4350 in 76
      replace weight = 4700 in 77
      
      replace weight = 4000 in 78
      replace weight = 4350 in 79
      replace weight = 4700 in 80
      
      replace mpg = 35 in 75
      replace mpg = 35 in 76
      replace mpg = 35 in 77
      
      replace mpg = 32.5 in 78
      replace mpg = 32.5 in 79
      replace mpg = 32.5 in 80
      
      replace foreign = 0 in 75
      replace foreign = 0 in 76
      replace foreign = 0 in 77
      
      replace foreign = 1 in 78
      replace foreign = 1 in 79
      replace foreign = 1 in 80
      
      replace pbubble = 1 in 75
      replace pbubble = 2 in 76
      replace pbubble = 3 in 77
      
      replace pbubble = 1 in 78
      replace pbubble = 2 in 79
      replace pbubble = 3 in 80
      
      twoway (scatter mpg weight if foreign == 1 & pbubble == 1, msize(small) msymbol(circle_hollow)) ///
             (scatter mpg weight if foreign == 0 & pbubble == 1, mcolor(%50) msize(small) msymbol(circle)) ///
             (scatter mpg weight if foreign == 1 & pbubble == 2, msize(large) msymbol(circle_hollow)) ///
             (scatter mpg weight if foreign == 0 & pbubble == 2, mcolor(%50) msize(large) msymbol(circle)) ///
             (scatter mpg weight if foreign == 1 & pbubble == 3, msize(huge) msymbol(circle_hollow)) ///
             (scatter mpg weight if foreign == 0 & pbubble == 3, mcolor(%50) msize(huge) msymbol(circle)), ///
             text(37 4000 "Low Price") ///
             text(37 4350 "Med Price") ///
             text(37 4700 "High Price") ///
             text(35 3750 "Foreign") ///
             text(32.5 3750 "Domestic") ///
             legend(off) name(bubble)

      Comment

      Working...
      X