- matplotlib

Bar Chart







import matplotlib.pyplot as plt def my_function(*args, **kwargs): SelectInput = Element('SelectInput').element.value SelectInput = int(SelectInput) text = Element('test-input').element.value text_2 = Element('test-input-2').element.value text_3 = Element('test-input-3').element.value text_4 = Element('test-input-4').element.value text_5 = Element('test-input-5').element.value input_x = text list_x = input_x.split() input_y = text_2 list_y = input_y.split() map_object_y = map(int, list_y) listofint_y = list(map_object_y) Element('test-output').element.innerText = list_x Element('test-output-1').element.innerText = listofint_y Element('test-output-2').element.innerText = text_3 Element('test-output-3').element.innerText = text_4 Element('test-output-4').element.innerText = text_5 fig,ax = plt.subplots() title = text_3 plt.title(title) if SelectInput == 1: xlabel = text_4 plt.xlabel(xlabel) ylabel = text_5 plt.ylabel(ylabel) plt.bar(list_x,listofint_y) fig buffer = io.BytesIO() plt.savefig(buffer, format='png') buffer.seek(0) image_data = buffer.getvalue() base64_image = base64.b64encode(image_data).decode('utf-8') image_url = f'data:image/png;base64,{base64_image}' Element('quad').element.innerText = image_url if SelectInput == 2: xlabel = text_5 plt.xlabel(xlabel) ylabel = text_4 plt.ylabel(ylabel) plt.barh(list_x,listofint_y) fig buffer = io.BytesIO() plt.savefig(buffer, format='png', bbox_inches='tight') buffer.seek(0) image_data = buffer.getvalue() base64_image = base64.b64encode(image_data).decode('utf-8') image_url = f'data:image/png;base64,{base64_image}' Element('quad').element.innerText = image_url