cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
dale_lehman
Level VII

Need help getting (x,y) boxes drawn from data

I have a column with numeric X values and another with numeric Y values.  The X and Y values each contain a minimum and maximum value for a series of observations, such as

obs  dimension  min/max  value

1     X               min          1.1

1     X               max         1.5

1     Y               min          0.9

1     Y               max         1.25

I have 5-10 observations, each with coordinates like these.  I would like JMP to draw rectangles on an (x,y) plane with those coordinates.  Can anybody tell me how to do this?

Thanks.

3 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Need help getting (x,y) boxes drawn from data

Here is an example of taking your data and drawing a rectangle

Names Default To Here( 1 );

dt = New Table( "Untitled 18",
	Add Rows( 4 ),
	New Column( "dimension", Character, "Nominal", Set Values( {"X", "X", "Y", "Y"} ) ),
	New Column( "min/max", Character, "Nominal", Set Values( {"min", "max", "min", "max"} ) ),
	New Column( "value", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1.1, 1.5, 0, 1.25] ) )
);

dtSplit = dt << Split( Split By( :dimension, :Name( "min/max" ) ), Split( :value ), Sort by Column Property );

New Window( "Example",
	Graph Box(
		Y Scale( 0, 4 ),
		X Scale( 0, 4),
		Pen Color( "Green" );
		Pen Size( 2 );
		For( i = 1, i <= N Rows( dtSplit ), i++,
			Rect( dtSplit:X min[i], dtSplit:Y max[i], dtSplit:X max[i], dtSplit:Y min[i], 0 )
		);
	)
);

The Graph Box functions are all documented at:

     Help==>Scripting Index==>Graph Box 

Jim

View solution in original post

txnelson
Super User

Re: Need help getting (x,y) boxes drawn from data

There is very good documentation on Creating Maps in the Essential Graphing guide:
Help==>Books==>Essential Graphing
In JMP 13 it is Chapter 15, starting on page 303

I suspect your issue is placing the map on your desktop and getting JMP to be able to find it there. In my use of these maps, I always place them in the AutoLookup folders, and documented in the Essential Graphing guide
Jim

View solution in original post

txnelson
Super User

Re: Need help getting (x,y) boxes drawn from data

What I suspect that is going on, is that you are not defining the 4 points of your rectangle properly.  Since with a Shape Map, what you are really defining are polygons, they must be defined in a continuous order.  i.e. (top,left), (top,right), (bottom,right), (bottom,left).    

Jim

View solution in original post

6 REPLIES 6
txnelson
Super User

Re: Need help getting (x,y) boxes drawn from data

Here is an example of taking your data and drawing a rectangle

Names Default To Here( 1 );

dt = New Table( "Untitled 18",
	Add Rows( 4 ),
	New Column( "dimension", Character, "Nominal", Set Values( {"X", "X", "Y", "Y"} ) ),
	New Column( "min/max", Character, "Nominal", Set Values( {"min", "max", "min", "max"} ) ),
	New Column( "value", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1.1, 1.5, 0, 1.25] ) )
);

dtSplit = dt << Split( Split By( :dimension, :Name( "min/max" ) ), Split( :value ), Sort by Column Property );

New Window( "Example",
	Graph Box(
		Y Scale( 0, 4 ),
		X Scale( 0, 4),
		Pen Color( "Green" );
		Pen Size( 2 );
		For( i = 1, i <= N Rows( dtSplit ), i++,
			Rect( dtSplit:X min[i], dtSplit:Y max[i], dtSplit:X max[i], dtSplit:Y min[i], 0 )
		);
	)
);

The Graph Box functions are all documented at:

     Help==>Scripting Index==>Graph Box 

Jim
dale_lehman
Level VII

Re: Need help getting (x,y) boxes drawn from data

Thank you, that does what I want.  I was also thinking I might want to do this via creating a custom map, but I can't seem to get that to work.  I follow the example in the sample help file but I keep getting the message in graph builder that the shape file is not found.  I created the -Name and -XY files with the same shape ID column.  In the -NAME file I assigned the shape name definition role to the name of my shape(s).  I then created a new file with those names and some data and assigned the shape name use role to the column with the names - I put both the -NAME and -XY files in a new folder on my desktop and pointed to that folder in the shape name use role to tell JMP where to find the files.

I must be missing something - possibly where the paths to the files since I put them in a folder on my desktop.  If anyone has any idea how I may be going wrong, I'd appreciate some tips.

txnelson
Super User

Re: Need help getting (x,y) boxes drawn from data

There is very good documentation on Creating Maps in the Essential Graphing guide:
Help==>Books==>Essential Graphing
In JMP 13 it is Chapter 15, starting on page 303

I suspect your issue is placing the map on your desktop and getting JMP to be able to find it there. In my use of these maps, I always place them in the AutoLookup folders, and documented in the Essential Graphing guide
Jim
dale_lehman
Level VII

Re: Need help getting (x,y) boxes drawn from data

Thank you again - indeed, moving the name and shape files to the JMP map directory solved the problem.  If you can indulge one more question.  I want the shapes to be rectangles and I put in the coordinates of the 4 corners of the rectangle.  When I use graph builder and the map shape to display, I get the horizontal sides of each rectangle and diagonal lines connecting the corners, but no vertical lines for the sides of the rectangle.  I tried adding more points, but that does not seem to change anything.  Do you know why the coordinates for the 4 corners does not produce a rectangle but instead produces what I've described.  I am attempting to attach a screenshot but don't know if it will work.  Any ideas of how to change it to a rectangle would be appreciated.Capture.JPG

txnelson
Super User

Re: Need help getting (x,y) boxes drawn from data

What I suspect that is going on, is that you are not defining the 4 points of your rectangle properly.  Since with a Shape Map, what you are really defining are polygons, they must be defined in a continuous order.  i.e. (top,left), (top,right), (bottom,right), (bottom,left).    

Jim
dale_lehman
Level VII

Re: Need help getting (x,y) boxes drawn from data

Excellent!  Thank you so much this is a perfect solution.