// This script demonstrates how to generate an animation with Bubble Plot // and save it as an animated GIF. It uses the Hurricanes data table, // found in the samples directory and shows the hurricanes for 2008. // NOTE: This uses functionality added in Version 13, so V13 or later required. NamesDefaultToHere(1); // Open data table and create bubble plot with Time variable // Limit selection so this doesn't get too big dt = open("$SAMPLE_DATA/hurricanes.jmp"); //dt << select rows(1::20000); dt << select where (:year != 2008); dt << exclude; dt << hide; dt << invert row selection; bp = Bubble Plot( X( :Longitude ), Y( :Latitude ), Sizes( :Name( "Wind (Knots)" ) ), Time( :Date ), Coloring( :Landfall in USA ), ID( :Name and ID ), Speed( 60.44 ), Trail Bubbles( 1 ), Color Levels( [0 0.25 0.5 0.75 1] ), Title Position( -88.679, 59.73 ), SendToReport( Dispatch( {}, "1", ScaleBox, {Min( -110 ), Max( 10 ), Inc( 20 ), Minor Ticks( 0 ), Rotated Labels( "Horizontal" )} ), Dispatch( {}, "2", ScaleBox, {Min( 0 ), Max( 70 ), Inc( 10 ), Minor Ticks( 0 ), Rotated Labels( "Horizontal" )} ), Dispatch( {}, "Bubble Plot", FrameBox, {Frame Size( 465, 348 ), Background Map( Images( "Simple Earth" ) ), Grid Line Order( 3 ), Reference Line Order( 2 )} ) ) ); report = bp << report(); // Create a new image, same size as the graph we are going to capture graphFrame = report[FrameBox(1)] << getPicture(); {w, h} = graphFrame << getSize(); img = newImage(w, h); // Loop through the bubble plot animation // Min and max time values taken from step slider in bubble plot for (frame = 1, frame <= 93, frame++, // Capture frame for current graph and save to animated image graphFrame = report[FrameBox(1)] << getPicture(); {r, g, b} = graphFrame << getPixels("rgb"); img << addFrame(); img << setFrameDuration(200); // Time between frames, in ms img << setPixels("rgb", {r, g, b}); wait(0.01); // Two approaches to setting the time variable in Bubble Plot bp << step; // bp << timeIndex(frame); ); // Remove inital blank frame img << removeFrame(0); // Write out animated image img << saveImage ("animateHurricanes.gif", gif); // Close down graph window and data table bp << close Window; dt << close Window;