コード例 #1
0
##----------PLOT-------------------------  
#Create a styling dictionary for our plot
PLOT_OPS = {'title':'2010',
            'height':500,
            'width':900,
            'x_axis_type':'log',
            'x_axis_label':'Log(Income)',
            'y_axis_label':'Life expectancy (years)',
            'x_range':(100,100000),
            'y_range':(0,100),
            'toolbar_location':"below"
           }

#Create the population size mapper
size_mapper = LinearInterpolator(x=[data.loc[2010]['population'].min(),
                                    data.loc[2010]['population'].max()],
                                 y=[5,50])
    
#Create the region color mapper
color_mapper = CategoricalColorMapper(factors=data.loc[2010]['region'].unique(),
                                      palette=Spectral6)

#Construct the plot (just as in GapMinder-03-Interactivity.ipynb)
hover = HoverTool(tooltips='@Country')
p = figure(**PLOT_OPS)
p.circle(x='income',
         y='life',
         source=theCDS,
         size={'field':'population','transform':size_mapper},
         color={'field':'region','transform':color_mapper},
         alpha=0.6,