def response_time_area(self,path='',plot_log=True,threshold=5): """Draws graph of lengths of sessions per session. :param path: -- default is '' (current_dir) :param plot_log: whether to draw normal land area or log of land area -- default is True :param threshold: how many top countries to annotate """ if not path: path = self.current_dir+'/graphs/' data = analysis.response_time(self.frame) if not data.empty: areas = [] for i in data.iteritems(): areas += [self.codes[self.codes.id==i[0]]['area'].values[0]] fig,ax = plt.subplots() ax.set_xlabel(u"Mean response time") if plot_log: ax.set_ylabel(u"Log of land area of a country [km*km]") ax.set_yscale('log') areas = log(areas) else: ax.set_ylabel(u"Land area of a country [km*km]") plt.plot(data.values,areas,marker="o",ls='',color="cyan") '''data = data.sort(ascending=False) for i in range(threshold): ax.annotate(self.get_country_name(data.index[i]),(data[i],areas[i])) ax.annotate(self.get_country_name(data.index[i]),(data[-i],areas[-i]))''' plt.savefig(path+'response_time_area.svg', bbox_inches='tight') plt.close()
def response_time(self, binning_function=None, path="", number_of_bins=6): """Draws map of mean response time per country. :param binning_function: which function to use for binning -- default is None (-> jenks_classification) :param path: output directory -- default is '' (current dir) :param number_of_bins: how many bins to divide data into-- default is 6 """ if not path: path = self.current_dir + "/maps/" data = analysis.response_time(self.frame) colours = None if not data.empty: (data, colours) = self.bin_data(data, binning_function, number_of_bins) self.generate_css(data[["country", "rgb"]], path=self.current_dir + "/style.css") self.draw_map(path + "response_time.svg", "Response time", colours)