Icon

kn_​example_​python_​graphic_​boxenplot_​large_​distribution

KNIME & Python Graphics - Boxenplot Plotting large distributions
KNIME & Python Graphics - Boxenplot Plotting large distributionsadapted from: https://seaborn.pydata.org/examples/large_distributions.html import knime_io as knio#Import Libraryfrom io import BytesIOimport osimport pandas as pdimport seaborn as snssns.set_theme(style="whitegrid")# https://seaborn.pydata.org/examples/large_distributions.htmlinput_table = knio.input_tables[0].to_pandas()var_title = knio.flow_variables['title_graphic']var_footnote = knio.flow_variables['footnote_graphic']var_colour = knio.flow_variables['v_colour']var_x_variable = knio.flow_variables['variable_x']var_x_label = knio.flow_variables['label_x']var_y_a_variable = knio.flow_variables['variable_y_a']var_y_a_label = knio.flow_variables['label_y_a']var_kind_scale = knio.flow_variables['v_kind_scale']# set the rank ordervar_rank_order_x = knio.flow_variables['rank_order_x']var_rank_order_x2 = [str(x.strip()) for x in var_rank_order_x.split(',') if x]# var_rank_order_x2 = ["I1", "SI2", "SI1", "VS2", "VS1", "VVS2", "VVS1", "IF"]#define figure size# sns.set(rc={"figure.figsize":(16, 9)}) #width=8, height=4sns.set(rc={'figure.figsize':(16,9)})################################################### https://seaborn.pydata.org/examples/large_distributions.htmlg = sns.boxenplot(x=var_x_variable, y=var_y_a_variable, color=var_colour, order=var_rank_order_x2, scale="linear", data=input_table)g.set(xlabel=var_x_label, ylabel=var_y_a_label, title=var_title)##################################################fig_out = g.get_figure()fig_out.set_size_inches(16, 9)fig_out.text(0.1, 0.025, var_footnote ,fontsize=10)#add overall title# g.fig.suptitle(var_title)# Create buffer to write intobuffer = BytesIO()# Create plot and write it into the bufferfig_out.savefig(buffer, format='svg')# The output is the content of the bufferoutput_image = buffer.getvalue()knio.output_images[0] = output_image determine an additional sorting system Propagate Python environmentfor KNIME on Windows withMinicondaconfigure how to handle the environmentdefault = just check the names1.920 x 1.080PNG filefrom_knime_boxenplot_large_distribution.pngdiamonds.parquetflow_variables['var_py_version_pandas'] = pd.__version__flow_variables['var_py_version_numpy'] = np.__version__right mouse clickto set the parametersPropagate Python environmentfor KNIME on MacOSX withMinicondaconfigure how to handle the environmentdefault = just check the namesavg priceper Clarityavg priceper Clarityavg priceper Clarityrank_order_xrank_order_x1st = Python environment2nd = Rank of X-axis values conda_environment_kaggle_windows Image To Table Renderer to Image Table To Image Image Writer (Port) Parquet Reader Python EditVariable Python graphics - BoxenplotPlotting large distributions conda_environment_kaggle_macosx GroupBy Sorter GroupBy Column Rename Table Rowto Variable Merge Variables KNIME & Python Graphics - Boxenplot Plotting large distributionsadapted from: https://seaborn.pydata.org/examples/large_distributions.html import knime_io as knio#Import Libraryfrom io import BytesIOimport osimport pandas as pdimport seaborn as snssns.set_theme(style="whitegrid")# https://seaborn.pydata.org/examples/large_distributions.htmlinput_table = knio.input_tables[0].to_pandas()var_title = knio.flow_variables['title_graphic']var_footnote = knio.flow_variables['footnote_graphic']var_colour = knio.flow_variables['v_colour']var_x_variable = knio.flow_variables['variable_x']var_x_label = knio.flow_variables['label_x']var_y_a_variable = knio.flow_variables['variable_y_a']var_y_a_label = knio.flow_variables['label_y_a']var_kind_scale = knio.flow_variables['v_kind_scale']# set the rank ordervar_rank_order_x = knio.flow_variables['rank_order_x']var_rank_order_x2 = [str(x.strip()) for x in var_rank_order_x.split(',') if x]# var_rank_order_x2 = ["I1", "SI2", "SI1", "VS2", "VS1", "VVS2", "VVS1", "IF"]#define figure size# sns.set(rc={"figure.figsize":(16, 9)}) #width=8, height=4sns.set(rc={'figure.figsize':(16,9)})################################################### https://seaborn.pydata.org/examples/large_distributions.htmlg = sns.boxenplot(x=var_x_variable, y=var_y_a_variable, color=var_colour, order=var_rank_order_x2, scale="linear", data=input_table)g.set(xlabel=var_x_label, ylabel=var_y_a_label, title=var_title)##################################################fig_out = g.get_figure()fig_out.set_size_inches(16, 9)fig_out.text(0.1, 0.025, var_footnote ,fontsize=10)#add overall title# g.fig.suptitle(var_title)# Create buffer to write intobuffer = BytesIO()# Create plot and write it into the bufferfig_out.savefig(buffer, format='svg')# The output is the content of the bufferoutput_image = buffer.getvalue()knio.output_images[0] = output_image determine an additional sorting system Propagate Python environmentfor KNIME on Windows withMinicondaconfigure how to handle the environmentdefault = just check the names1.920 x 1.080PNG filefrom_knime_boxenplot_large_distribution.pngdiamonds.parquetflow_variables['var_py_version_pandas'] = pd.__version__flow_variables['var_py_version_numpy'] = np.__version__right mouse clickto set the parametersPropagate Python environmentfor KNIME on MacOSX withMinicondaconfigure how to handle the environmentdefault = just check the namesavg priceper Clarityavg priceper Clarityavg priceper Clarityrank_order_xrank_order_x1st = Python environment2nd = Rank of X-axis values conda_environment_kaggle_windows Image To Table Renderer to Image Table To Image Image Writer (Port) Parquet Reader Python EditVariable Python graphics - BoxenplotPlotting large distributions conda_environment_kaggle_macosx GroupBy Sorter GroupBy Column Rename Table Rowto Variable Merge Variables

Nodes

Extensions

Links