cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
NRW
NRW
Level IV

Overlay a graph onto another graph

Folks,

 

What are the ways (or best way) to overlay another graph onto another as shown in first attachment? Final objective is to generate multiple plots, arrange them in a window that is saved as a table property. This table property is then run so the final composite picture is able to be copied and pasted to Powerpoint.

 

The script I have so far almost gets me there (see attached script and 2nd attachment). My current script obviously goes into the Report for each generated graph and a "Get Picture" command is used to populate the Lineup Box. I have tried to treat the Histogram only as an image, and do an "Add Image", but was not able to make it work. 

 

If an Add Image command is the way to go, my additional question is to how to appropriately come up with the "bounds" arguments to position properly?

 

Neil

	cr = Current Data Table() << Run Script("Cumulative Resistivity");
	rpt_cr = Report(cr);
	rpt_cr_pic = rpt_cr[PictureBox(1)] << Get Picture;
	
	
	ds = Current Data Table() << Run Script("Distribution");
	rpt_ds = Report(ds);
	rpt_ds_pic = rpt_ds[ListBox(4)] << Get Picture;
	
	
	//comb = New Image( rpt_ds_pic );
	//rpt_cr_pic << Add Image( comb, bounds(left(0), top(500),bottom(0),right(724)));
	
	
	nw = Eval Expr( New Window("BR",  
						a = V List Box(
							Lineup Box(N Col(2), rpt_cr_pic, rpt_ds_pic ), 
							 )
							
						)
					);
							
	
	Current Data Table() << New Script("RP", nw) ;

 

 

overlay_1.PNG

 

 

 

overlay_2.PNG

 

 

 

 

Neil
4 REPLIES 4
NRW
NRW
Level IV

Re: Overlay a graph onto another graph

Just for clarity, I'm trying to overlay a picture of a graph (via get picture) over another graph picture. 

 

So per the script I'm getting the "rpt_ds_pic" picture and trying to overlay onto rpt_cr_pic. However, I'm only getting the rpt_cr_pic for my output, the added pic is not showing up.

 

I've gone through the scripting index (Add Image) and Scripting guide, but I'm obviously I'm not grasping a fundamental concept that makes this work.

 

Any hint or direction would be extremely helpful .

 

Many thanks.

Neil

 

 

 

cr = Current Data Table() << Run Script("Cumulative Resistivity");
	rpt_cr = Report(cr);
	rpt_cr_pic = rpt_cr[PictureBox(1)] << Get Picture;
	
	
	ds = Current Data Table() << Run Script("Distribution");
	rpt_ds = Report(ds);
	rpt_ds_pic = rpt_ds[PictureBox(1)] << Get Picture;
	
	
	comb = New Image( rpt_ds_pic );
	rpt_cr_pic << Add Image( comb, bounds(left(0), top(500),bottom(0),right(724)));
	
	
	nw = Eval Expr( New Window("BR",  
						a = V List Box(
							Lineup Box(N Col(2), rpt_cr_pic, /*rpt_ds_pic*/ ), 
							 )
							
						)
					);
							
	
	Current Data Table() << New Script("RP", nw) ;

 

Neil

Re: Overlay a graph onto another graph

Hi,

 

The only way I know to do this is as follows:

1) Get your images and get the matrices of pixels for them.

2) Overwrite a submatrix of the "lower" image's pixels with the pixel matrix of the "upper" image.

 

Below is a script illustrating this, and an image (actually a window of 3 images where the "top" image has been "pasted" in different locations) showing the results. You may have to experiment to get your image where you want it, but this approach should eventually do the trick.

 

names default to here(1);

//make a table
dt = astable(J(50,2,randomuniform()));

//make a graph
gb = dt << Graph Builder(
	Size( 500, 500 ),
	Show Control Panel( 0 ),
	Variables( X( :col1 ), Y( :col2 ) ),
	Elements( Points( X, Y, Legend( 5 ) ) ),
);

//save to a picture, get the pixels and get the picture's x and y dimemnsions
pic1 = (report(gb)[framebox(1)] << get picture) << get pixels;
pic1y = nrow(pic1);
pic1x = ncol(pic1);

//now make another graph and do the same
dist = dt << distribution(histograms only, y(:col1));
pic2 = (report(dist)[framebox(1)] << get picture) << get pixels;
pic2y = nrow(pic2);
pic2x = ncol(pic2);

//create a window to place the resulting images
nw = new window("xx", 
	vlb = vlistbox(
		
	)
);

x = y = 1; //initial "corner" of overwritten pixels... we will increment these and do 3 total pictures

for(i = 1, i<=3, i++,
	newPic = pic1;
	newPic[ y::(y+pic2y-1), x::(x+pic2x-1), ] = pic2;
	vlb << append(picturebox(new image(newPic)));
	y += 60;
	x+= 150;
);

brady_brady_0-1623969488765.png

 

Cheers,

Brady

 

 

 

NRW
NRW
Level IV

Re: Overlay a graph onto another graph

Brady,

 

I just got something that seemed to work earlier today, but I want to take a crack at your approach as well. 

 

Based off the "Add Image" command (and example) in the Scripting index, I was able to get the image shown below. My only issue was that the Graph Box seemed to be the only Display Element Box that allowed me to get the result. Also, X and Y axis are still present, and I'm not sure how to hide them. My code is attached.

 

Neil

 

overlay_3.PNG

Neil
NRW
NRW
Level IV

Re: Overlay a graph onto another graph

cr = Current Data Table() << Run Script("Cumulative Resistivity");
	rpt_cr = Report(cr);
	
	rpt_cr_pic = rpt_cr[PictureBox(1)] << Get Picture ;
	Print(rpt_cr_pic << Get Size);
	
	
	
	cp = Current Data Table() << Run Script("Cumulative Permeability");
	rpt_cp = Report(cp);
	rpt_cp_pic = rpt_cp[PictureBox(1)] << Get Picture;
	Print(rpt_cp_pic << Get Size);
	
	
	ds = Current Data Table() << Run Script("Distribution");
	rpt_ds = Report(ds);
	rpt_ds_pic = rpt_ds[PictureBox(1)] << Get Picture;
	
	
	
	
	g = Graph Box(
			FrameSize( 750, 1000 ),
			X Scale( 0, 100 ),
			Y Scale( 0, 100 ), 
							
			<<Add Image(
				image(rpt_ds_pic),Move(76,76)),
								
			<<Add Image(
				image(rpt_cr_pic), Move(50,75)),
								
			<<Add Image(
				image(rpt_cp_pic), Move(50,25)),										
		
	);
	
	
	nw = Eval Expr( New Window("BR", g ));
					
	Current Data Table() << New Script("RP", nw) ;
Neil