import matplotlib.patches as mpatches % matplotlib inline plt . style . use ([ 'classic' , 'ggplot' ]) plt . rcParams . update ({ 'figure.figsize' : ( 10.0 , 6.0 ), 'font.size' : 8 }) trending_roles = np . unique ( dfrt [ 'role' ]) roles_colors = cm . rainbow ( np . linspace ( 0 , 1 , len ( trending_roles ))) publish_dates = np . unique ( dfrt [ 'publish_date' ]) y = [] for i , role in enumerate ( trending_roles ): role_y = [] for j , date in enumerate ( publish_dates ): dfrs = dfrt . query ( 'role == @role & publish_date == @date' ) count = 0 if len ( dfrs [ 'count' ]) == 0 else dfrs [ 'count' ] . values [ 0 ] role_y . append ( count ) y . append ( role_y ) # define data points for stackplot x = publish_dates y = np . row_stack ( y ) percent = np . divide ( y , y . sum ( axis = 0 ) . astype ( float ) * 100 ) fig = plt . figure () ax = fig . add_subplot ( 111 ) ax . stackplot ( x , percent , colors = roles_colors ) ax . set_title ( 'Level of participation in surveys by role across time' ) ax . set_ylabel ( 'Percent (%)' ) # creating the legend manually plt . legend ([ mpatches . Patch ( color = roles_colors [ i ]) for i , role in enumerate ( trending_roles )], trending_roles , bbox_to_anchor = ( 1.05 , 1 ), loc = 2 , borderaxespad = 0. ) display ( md ( '## Level of participation in surveys by role' )) display ( md ( """ This initial graph aims to help understanding who participated in the surveys on each period. It is very important to understand the universe of samples, which may be a segment of the entire tech community in Argentina. There're reasons to think on this. A valid one is that SysArmy may have started as group of sysadmins/security guys -mainly, perhaps due to the topics they post about-, then spreaded more to the devs community. In order to prove this hypothesis, we graph the percentual level of participation by role (only top roles). """ )) plt . show () display ( md ( """ The results threw that Developers were from the beginning the majority group. This is against the initial hypothesis, but not so falsy, neither the last conclusion: 1. It is clearly visible that the Developers group has grew through time starting on September 2015. 2. Helpdesk however, have decreased since February 2016. 3. "Storage / Backup" have falled and then dissapeared. 4. "Otro" (others) has been raising from the begining -then dissapeared-, but marked the tendency of the universe of samples which tends to diverge in respect to the role. 5. The rest of roles maintain some consistency over time. """ ))