def apply_plot( x: List[float], y: List[float], parameters: Optional[Dict[Union[str, Parameters], Any]] = None) -> str: """ Plot (non-logarithmic way) the graph with axis values contained in x and y Parameters ------------ x Values for x-axis y Values for y-axis parameters Parameters of the algorithm, including: Parameters.FORMAT -> Format of the target image Parameters.TITLE -> Title of the image Returns ------------ temp_file_name Representation temporary file name """ if parameters is None: parameters = {} format = exec_utils.get_param_value(Parameters.FORMAT, parameters, "png") title = exec_utils.get_param_value(Parameters.TITLE, parameters, GRAPH_DEFAULT_TITLE) x_axis = exec_utils.get_param_value(Parameters.X_AXIS, parameters, TIMESTAMP_LABEL) y_axis = exec_utils.get_param_value(Parameters.Y_AXIS, parameters, DENSITY_LABEL) filename = common.get_temp_file_name(format) current_backend = copy(matplotlib.get_backend()) matplotlib.use('Agg') from matplotlib import pyplot pyplot.clf() pyplot.plot(x, y) pyplot.xlabel(x_axis) pyplot.ylabel(y_axis) pyplot.title(title) pyplot.xticks(rotation=90) pyplot.savefig(filename, bbox_inches="tight", transparent=True) pyplot.clf() matplotlib.use(current_backend) return filename
def apply_plot( x: List[float], y: List[float], parameters: Optional[Dict[Union[str, Parameters], Any]] = None) -> str: """ Visualizes a barchar provided its x-axis and y-axis points Parameters ----------------- x X-axis points y Y-axis points parameters Parameters Returns ----------------- tmp_file_name Temporary file name """ if parameters is None: parameters = {} title = exec_utils.get_param_value(Parameters.TITLE, parameters, "") format = exec_utils.get_param_value(Parameters.FORMAT, parameters, "png") x_axis = exec_utils.get_param_value(Parameters.X_AXIS, parameters, "") y_axis = exec_utils.get_param_value(Parameters.Y_AXIS, parameters, "") filename = common.get_temp_file_name(format) current_backend = copy(matplotlib.get_backend()) matplotlib.use('Agg') from matplotlib import pyplot pyplot.clf() fig = pyplot.figure() ax = fig.add_axes([0, 0, 1, 1]) ax.bar(x, y) pyplot.xlabel(x_axis) pyplot.ylabel(y_axis) pyplot.title(title) pyplot.savefig(filename, bbox_inches="tight", transparent=True) pyplot.clf() matplotlib.use(current_backend) return filename
def apply_semilogx(x, y, parameters=None): """ Plot (semi-logarithmic way) the graph with axis values contained in x and y Parameters ------------ x Values for x-axis y Values for y-axis parameters Parameters of the algorithm, including: Parameters.FORMAT -> Format of the target image Parameters.TITLE -> Title of the image Returns ------------ temp_file_name Representation temporary file name """ if parameters is None: parameters = {} format = exec_utils.get_param_value(Parameters.FORMAT, parameters, "png") title = exec_utils.get_param_value(Parameters.TITLE, parameters, GRAPH_DEFAULT_TITLE) filename = common.get_temp_file_name(format) current_backend = copy(matplotlib.get_backend()) matplotlib.use('Agg') from matplotlib import pyplot pyplot.clf() pyplot.semilogx(x, y) pyplot.xlabel(TIMESTAMP_LABEL) pyplot.ylabel(DENSITY_LABEL) pyplot.title(title) pyplot.xticks(rotation=90) pyplot.savefig(filename, bbox_inches="tight", transparent=True) pyplot.clf() matplotlib.use(current_backend) return filename
def apply_plot(x, y, parameters=None): """ Plot (non-logarithmic way) the graph with axis values contained in x and y Parameters ------------ x Values for x-axis y Values for y-axis parameters Parameters of the algorithm, including: format -> Format of the target image Returns ------------ temp_file_name Representation temporary file name """ if parameters is None: parameters = {} format = parameters["format"] if "format" in parameters else "png" title = parameters[ "title"] if "title" in parameters else GRAPH_DEFAULT_TITLE filename = common.get_temp_file_name(format) current_backend = copy(matplotlib.get_backend()) matplotlib.use('Agg') from matplotlib import pyplot pyplot.clf() pyplot.plot(x, y) pyplot.xlabel(TIMESTAMP_LABEL) pyplot.ylabel(DENSITY_LABEL) pyplot.title(title) pyplot.xticks(rotation=90) pyplot.savefig(filename, bbox_inches="tight", transparent=True) pyplot.clf() matplotlib.use(current_backend) return filename
def apply_semilogx(x, y, parameters=None): """ Plot (semi-logarithmic way) the graph with axis values contained in x and y Parameters ------------ x Values for x-axis y Values for y-axis parameters Parameters of the algorithm, including: format -> Format of the target image Returns ------------ temp_file_name Representation temporary file name """ if parameters is None: parameters = {} format = parameters["format"] if "format" in parameters else "png" title = parameters[ "title"] if "title" in parameters else GRAPH_DEFAULT_TITLE filename = common.get_temp_file_name(format) pyplot.clf() pyplot.semilogx(x, y) pyplot.xlabel(TIMESTAMP_LABEL) pyplot.ylabel(DENSITY_LABEL) pyplot.title(title) pyplot.xticks(rotation=90) pyplot.savefig(filename, bbox_inches="tight") pyplot.clf() return filename