onwebkerop.blogg.se

Mysql python jupyter notebook
Mysql python jupyter notebook













Figure ( data = data, layout = layout ) # Send to Plotly and show in notebook py. Layout ( title = title, # set plot title plot_bgcolor = '#EFECEA', # set plot color to grey hovermode = "closest", xaxis = dict ( axis_style, # add axis style dictionary title = x_title, # x-axis title range =, # log of min and max x limits ), yaxis = dict ( axis_style, # add axis style dictionary title = y_title, # y-axis title ) ) # Make Figure object fig = go. append ( make_trace ( X, continent, sizes, color ) # append trace to data object ) # Set plot and axis titles title = "Life expectancy vs GNP from MySQL world database (bubble chart)" x_title = "Gross National Product" y_title = "Life Expectancy " # Define a dictionary of axis style options axis_style = dict ( type = 'log', zeroline = False, # remove thick zero line gridcolor = '#FFFFFF', # white grid lines ticks = 'outside', # draw ticks outside axes ticklen = 8, # tick length tickwidth = 1.5 # and width ) # Make layout object layout = go. groupby ( 'Continent' ): sizes = X # get population array color = colors # get bubble color data. tolist (), marker = dict ( color = color, # marker color size = sizes, # (!) marker sizes (sizes is a list) sizeref = sizeref, # link sizeref sizemode = sizemode, # link sizemode opacity = 0.6, # (!) partly transparent markers line = dict ( width = 3, color = "white" ) # marker borders ) ) # Initialize data object data = # Group data frame by continent sub-dataframe (named X), # make one trace object per continent and append to data object for continent, X in df. Scatter ( x = X, # GDP on the x-xaxis y = X, # life Exp on th y-axis name = continent, # label continent names on hover mode = 'markers', # (!) point markers only on this plot text = X. % ( X, X, X / 1e6 ) # Define a trace-generating function (returns a Scatter object) def make_trace ( X, continent, sizes, color ): return go. max () / 1e2 ** 2 colors = # Define a hover-text generating function (returns a list of strings) def make_text ( X ): return 'Country: %s \ Life Expectancy: %s years \ Population: %s million'\ # Here the max bubble area will be on the order of 100 pixels sizeref = df. This makes the range of bubble sizes smaller sizemode = 'area' # (!) Set a reference for 'size' values (i.e. The python language becomes versatile in numerous filed all over the globe. # (!) Set 'size' values to be proportional to rendered area, # instead of diameter. In this article, we will do CRUD operation in the database using python language in the jupyter notebook.















Mysql python jupyter notebook