Creating a Histogram with FreeFlyer

General FreeFlyer Discussion.
Zach Mason 66293da0042da
Posts: 2
Joined: Wed Apr 24, 2024 5:13 pm
Creating a Histogram with FreeFlyer

Post by Zach Mason 66293da0042da »

The following code is an example of how to plot a histogram in FreeFlyer. In order to do this, you need to set up an array with your bins and an array with the number of values in each bin. The code then creates a strait vertical line with evenly spaced points. The length of the line is based on the number of points in the bin and each bin is created with its own strait line. The plot is created using a PlotWindow and PlotScatterSeries. For your histogram inputs, it can be simplified by creating a list of structs for each bin with relevant information. I might turn this into a procedure in the future if someone asks but for now enjoy the example.






//create Plot window

//create plot window
PlotWindow Histogram;
//create a plot series for each sensor
List <PlotScatterSeries> plotSensors;//serves as the bin
plotSensors.Count = FlagCount; //number of bins to plot

Report "The number of unique and uncalibrated sensors are: ", FlagCount.ToString to Console;
Report " " to Console;


// Pretty Plots Ranges
Histogram.PlotTitle.Text = Title;
Histogram.XAxis.Title.Text = "Sensor Name";
Histogram.YAxis.Title.Text = "# of Uncalibrated instances";
Histogram.SetSeriesColorPalette("Pastel");
Histogram.SetBackgroundColorPalette("DarkGray");
Histogram.SetLineWidth(10);
Histogram.SetLineVisibility(1);
Histogram.SetMarkerSize(2);
Histogram.SetMarkerVisibility(1);

// creat plot for each sensor
i=0;
k=1;
While (k < EXOSensors.Count-1);


//if the value of the sensor count is one change the lot flag to zero
If (EXOSensors[k].SensorCount <= 2);
EXOSensors[k].Flag = 0;
End;
//check for plot flag
If (EXOSensors[k].Flag == 1);


//create and label scatterseries for sensor
//plotSensors = ColorTools.DarkViolet;
plotSensors.MarkersColor = ColorTools.DarkViolet;
plotSensors.MarkersStyle = 3;
plotSensors.ShowInLegend = 1;

//adjust this to change bucket size
plotSensors.LineWidth = BucketWidth;
plotSensors.Label = EXOSensors[k].SensorName;

//fill y values
BucketValues.Dimension = BucketFill;
BucketValues.FillLinspace(0,EXOSensors[k].SensorCount);

//fill x values for bucket
BucketNumber.Dimension = BucketFill;
BucketNumber.Fill(BucketNumberValue);

//add scaterplot values to plot windows
Histogram.AddSeries(plotSensors);
plotSensors.AddPoints(BucketNumber,BucketValues);
BucketNumberValue += BucketSeparation; //separation between each bucket
Update Histogram;
i++;
End;
k++;
End;
Attachments
Example of a freeflyer histogram.
Example of a freeflyer histogram.
Screenshot 2024-04-30 135253.png (67.92 KiB) Viewed 37608 times