Icon

kn_​example_​python_​graphic_​anova_​three_​way

KNIME & Python Graphics - Plotting a three-way ANOVA

KNIME & Python Graphics - Plotting a three-way ANOVA
(Draw a pointplot to show numeric value as a function of three categorical factors)

adapted from: https://seaborn.pydata.org/examples/pointplot_anova.html

KNIME & Python Graphics - Plotting a three-way ANOVA(Draw a pointplot to show numeric value as a function of three categorical factors)adapted from: https://seaborn.pydata.org/examples/pointplot_anova.html import knime.scripting.io as knio#Import Libraryfrom io import BytesIOimport osimport pandas as pdimport seaborn as snsimport matplotlib as mplimport matplotlib.pyplot as pltinput_table = knio.input_tables[0].to_pandas()var_title = knio.flow_variables['title_graphic']var_footnote = knio.flow_variables['footnote_graphic']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_y_b_variable = knio.flow_variables['variable_y_b']var_y_b_label = knio.flow_variables['label_y_b']var_y_c_variable = knio.flow_variables['variable_y_c']var_y_c_label = knio.flow_variables['label_y_c']var_kind_plot = knio.flow_variables['v_kind_plot']var_colour_pal = knio.flow_variables['v_colour_pal']sns.set_theme(style="whitegrid")sns.set(rc={'figure.figsize':(16,9)})################################################### https://seaborn.pydata.org/examples/pointplot_anova.html# Draw a pointplot to show pulse as a function of three categorical factorsg = sns.catplot(x=var_x_variable, y=var_y_a_variable, hue=var_y_b_variable, col=var_y_c_variable, # capsize=.2, palette=var_colour_pal, height=6, aspect=.75, kind=var_kind_plot, data=input_table)g.despine(left=True)g.set_axis_labels(var_x_label, var_y_a_label)g.fig.set_size_inches(16, 9)#add overall titleg.fig.suptitle(var_title, y=1.025)g.fig.text(0.025, -0.025, var_footnote ,fontsize=10)################################################### Create buffer to write intobuffer = BytesIO()# Create plot and write it into the bufferg.savefig(buffer, format='svg')# The output is the content of the bufferoutput_image = buffer.getvalue()knio.output_images[0] = output_image 1.920 x 1.080PNG file from_knime_anova_3way.pngexercise.parquetknio.flow_variables['var_py_version_pandas'] = pd.__version__knio.flow_variables['var_py_version_numpy'] = np.__version__knio.flow_variables['var_py_version'] = sys.version_infoknio.flow_variables['var_sys_path'] = sys.pathright mouse clickto set the parametersvar_path_imgvar_path_imgvar_*Image To Table Renderer to Image Table To Image Image Writer (Port) Parquet Reader Python Script Python graphics - Plottinga three-way ANOVA Java EditVariable (simple) String to Path(Variable) Variable toTable Row KNIME & Python Graphics - Plotting a three-way ANOVA(Draw a pointplot to show numeric value as a function of three categorical factors)adapted from: https://seaborn.pydata.org/examples/pointplot_anova.html import knime.scripting.io as knio#Import Libraryfrom io import BytesIOimport osimport pandas as pdimport seaborn as snsimport matplotlib as mplimport matplotlib.pyplot as pltinput_table = knio.input_tables[0].to_pandas()var_title = knio.flow_variables['title_graphic']var_footnote = knio.flow_variables['footnote_graphic']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_y_b_variable = knio.flow_variables['variable_y_b']var_y_b_label = knio.flow_variables['label_y_b']var_y_c_variable = knio.flow_variables['variable_y_c']var_y_c_label = knio.flow_variables['label_y_c']var_kind_plot = knio.flow_variables['v_kind_plot']var_colour_pal = knio.flow_variables['v_colour_pal']sns.set_theme(style="whitegrid")sns.set(rc={'figure.figsize':(16,9)})################################################### https://seaborn.pydata.org/examples/pointplot_anova.html# Draw a pointplot to show pulse as a function of three categorical factorsg = sns.catplot(x=var_x_variable, y=var_y_a_variable, hue=var_y_b_variable, col=var_y_c_variable, # capsize=.2, palette=var_colour_pal, height=6, aspect=.75, kind=var_kind_plot, data=input_table)g.despine(left=True)g.set_axis_labels(var_x_label, var_y_a_label)g.fig.set_size_inches(16, 9)#add overall titleg.fig.suptitle(var_title, y=1.025)g.fig.text(0.025, -0.025, var_footnote ,fontsize=10)################################################### Create buffer to write intobuffer = BytesIO()# Create plot and write it into the bufferg.savefig(buffer, format='svg')# The output is the content of the bufferoutput_image = buffer.getvalue()knio.output_images[0] = output_image 1.920 x 1.080PNG file from_knime_anova_3way.pngexercise.parquetknio.flow_variables['var_py_version_pandas'] = pd.__version__knio.flow_variables['var_py_version_numpy'] = np.__version__knio.flow_variables['var_py_version'] = sys.version_infoknio.flow_variables['var_sys_path'] = sys.pathright mouse clickto set the parametersvar_path_imgvar_path_imgvar_*Image To Table Renderer to Image Table To Image Image Writer (Port) Parquet Reader Python Script Python graphics - Plottinga three-way ANOVA Java EditVariable (simple) String to Path(Variable) Variable toTable Row

Nodes

Extensions

Links