hi all,
does anyone have experience producing bubble plots with uneven time spaces?
in Bubble plots the time dimension is rather limited. It is not a real time dimension but rather animates row by row. Therfore, when attempting to animate real log data events with uneven time differences the animation is disrespectful to the time.
in the attached file there is a log of events - each row is an event - in which an individual (ID) is locatad in an X, Y space. at each row there is a time reading of the event. the bubble plot script in the file animates row by row without properly accommodating for the different durations of each.
The following script inflates the data table so each row is just one minute and produces a more honest representation of the space over time.
i would apriciate any comments on the matter.
// first open the attached table "Bubble Plot2"
// then run the scrtipt.
dt = Current Data Table();
// original table is usually sorted by time of registration.
// Sort by ID to allow the calculation of duration per event for each ID.
dt << sort( by( ID ), Ascending, replace table( 1 ) );
// Add a column to calculate the duration of each event.
dt << New Column( "Event Duration",
Numeric,
Continuous,
Format( "Best", 6 ),
Formula(
If(
ID == Lag( ID, -1 ), Date Difference( :time, Lag( :time, -1 ), "minute", "actual" ),
// this was supposed to calculate a hypothetical duration until the last event in the data set but does not work.
Date Difference( :time, Col Max( time ) ), "minute",
"actual"
)
),
);
dt << run formulas;
Column( dt, "Event Duration" ) << delete formula;
// Record the original length of the table before adding rows.
// Using Nrow() directly in the For loop will produce an endless loop.
rowN = N Row();
// For each original row, produce new rows as many as the duration of each event.
For( i = 1, i <= rowN, i++,
rowi = dt << get row( i );
For( z = 1, z <= (:Name( "Event Duration" )[i] - 1), z++,
z;
dt << add row( rowi );
dt << run formulas;
);
);
// sort the data table once again in order to simplify the next formula.
dt << sort( by( ID, time ), Ascending, replace table( 1 ) );
// Add new column with actual time for each row.
New Column( "Real time",
Numeric,
Continuous,
Format( "yyyy-mm-ddThh:mm", 16 ),
Input Format( "yyyy-mm-ddThh:mm" ),
Formula(
If(
Row() == 1, :time,
:ID > Lag( :ID, 1 ), :time,
// this will add a minute to the previous time indication.
Lag( :Real time, 1 ) + 60
)
),
);
// Set marker the color by ID
Current Data Table() << Color by Column(
ID,
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
);;
// produce the bubble plot with actual time indication.
Bubble Plot(
X( :x ),
Y( :y ),
Time( :Real time ),
ID( :ID ),
Title Position( 1.61111111111111, 2.7 ),
SendToReport(
Dispatch(
{},
"Bubble Plot of y by x Across Real time ID ID",
OutlineBox,
{Set Title( "Bubble Plot of y by x Across Real time ID ID - Correct time intervals!!!" )}
),
Dispatch( {}, "1", ScaleBox, {Min( 0.5 ), Max( 3.5 ), Inc( 0.5 ), Minor Ticks( 1 ), Rotated Labels( "Horizontal" )} ),
Dispatch( {}, "2", ScaleBox, {Min( 0.5 ), Max( 3.5 ), Inc( 0.5 ), Minor Ticks( 1 ), Rotated Labels( "Horizontal" )} )
)
);