This example shows how to create a Custom display script window to display a scatter plot from any number of input signals. This code is used by a custom tool "Scatter plot 2D".

A number of different plotting parameters can be set in the script. Those will be used in the calls of Julia plot function.


The script excepts only an even number of input signal parameters. For each pair of input windows, it adds a new series to the plot. Please note that the first pair of windows is used to create a new plot (plot(...) function call). Subsequent window pairs are used to add new series to an existing plot (plot!(...) function calls).



#Displays scatter plot for 2 input vectors of the same size


using Plots


function process( input_windows::Array{SigviewWindow} )

  

  #PARAMETERS

  p_legend = true

  p_markershape = :circle

  p_markersize = 5

  p_markeralpha = 0.6

  p_markercolor = :auto

  p_markerstrokewidth = 1

  p_markerstrokealpha = 0.2

  p_markerstrokecolor = :black

  p_markerstrokestyle = :dot

  p_regression_line = false

  p_thickness_scaling = 1

  #PARAMETERS


  if  length( input_windows ) < 2 || false == iseven( length( input_windows ) )

   setDisplayText( "Scatter plot can be applied only to the even number of input signal windows (use Control Window)" )

   return

  end

  

  new_plot = plot(input_windows[1].samples, 

                  input_windows[2].samples, 

                            seriestype = :scatter, 

                          legend = p_legend,

                          markershape = p_markershape,

                          markersize = p_markersize,

                          markeralpha = p_markeralpha,

                          markercolor = p_markercolor,

                          markerstrokewidth = p_markerstrokewidth,

                          markerstrokealpha = p_markerstrokealpha,

                          markerstrokecolor = p_markerstrokecolor,

                          markerstrokestyle = p_markerstrokestyle,

                          smooth = p_regression_line,

                          thickness_scaling = p_thickness_scaling )  

  

  for i in 3:2:length( input_windows )

         new_plot = plot!(input_windows[i].samples, 

                    input_windows[i+1].samples, 

                            seriestype = :scatter, 

                            legend = p_legend,

                            markershape = p_markershape,

                        markersize = p_markersize,

                            markeralpha = p_markeralpha,

                            markercolor = p_markercolor,

                            markerstrokewidth = p_markerstrokewidth,

                            markerstrokealpha = p_markerstrokealpha,

                            markerstrokecolor = p_markerstrokecolor,

                            markerstrokestyle = p_markerstrokestyle,

                            smooth = p_regression_line,

                            thickness_scaling = p_thickness_scaling )  

  end

  

  displayPlotInSigview(  new_plot )

end