Icon

kn_​example_​python_​graphic_​kde_​joint_​plot

KNIME & Python Graphics - Joint kernel density estimate with Seaborn (compare tow numeric variables and plot by a group)

KNIME & Python Graphics - Joint kernel density estimate with Seaborn (compare tow numeric variables and plot by a group)

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

KNIME & Python Graphics - Joint kernel density estimate with Seaborn (compare tow numeric variables and plot by a group)adapted from: https://seaborn.pydata.org/examples/joint_kde.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_kind_plot = knio.flow_variables['v_kind_plot']sns.set_theme(style="ticks")sns.set(rc={'figure.figsize':(16,9)})################################################### https://seaborn.pydata.org/examples/joint_kde.htmlg = sns.jointplot( data=input_table, x=var_x_variable, y=var_y_a_variable, hue=var_y_b_variable, kind=var_kind_plot,)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 locate and create/data/ folderwith absolute paths1.920 x 1.080PNG filefrom_knime_joint_plot.pngpenguins.parquetright mouse clickto set the parametersvar_path_imgvar_path_img Collect LocalMetadata Image To Table Renderer to Image Table To Image Image Writer (Port) Parquet Reader Python graphics - Jointkernel density estimate Java EditVariable (simple) String to Path(Variable) KNIME & Python Graphics - Joint kernel density estimate with Seaborn (compare tow numeric variables and plot by a group)adapted from: https://seaborn.pydata.org/examples/joint_kde.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_kind_plot = knio.flow_variables['v_kind_plot']sns.set_theme(style="ticks")sns.set(rc={'figure.figsize':(16,9)})################################################### https://seaborn.pydata.org/examples/joint_kde.htmlg = sns.jointplot( data=input_table, x=var_x_variable, y=var_y_a_variable, hue=var_y_b_variable, kind=var_kind_plot,)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 locate and create/data/ folderwith absolute paths1.920 x 1.080PNG filefrom_knime_joint_plot.pngpenguins.parquetright mouse clickto set the parametersvar_path_imgvar_path_img Collect LocalMetadata Image To Table Renderer to Image Table To Image Image Writer (Port) Parquet Reader Python graphics - Jointkernel density estimate Java EditVariable (simple) String to Path(Variable)

Nodes

Extensions

Links