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
Zack94
Level I

Draw a rectangle but X and Y are in the same column

I need to draw some rectangles, similarly to what is shown in this reply

In my case i have data organized differently:

 

Parameter Value

X                1

Y                2

 

Is there a simple way withouth splitting the row in X and Y columns?

Thank you

 

8 REPLIES 8
jthi
Super User

Re: Draw a rectangle but X and Y are in the same column

How are different coordinates mapped together (how do you know which X belongs to which Y)? How does your more full data look like (difficult to create a rectangle with just one? coordinate)? What type of rectangle do you need? Graph Builder? Graph Box?

 

Easiest way would most likely be splitting but there could be other methods (maybe some simple and some not simple)

-Jarmo
Zack94
Level I

Re: Draw a rectangle but X and Y are in the same column

Essentially I have a table similar to this:

 

ID Parameter Value

1   X size        10

1   Y size        15

2   X size        11

2   Y size        14

 

And i want to superimpose graphically the two rectangles in order to compare the dimensions.

 

jthi
Super User

Re: Draw a rectangle but X and Y are in the same column

Graph Box with Rect is one option if you just want to see the rectangles

Names Default To Here(1);
nw = New Window("Example",
	gb = Graph Box(
		Frame Size(300, 300),
		Pen Size(1);
		Pen Color("Blue");
		Rect(0, 15, 10, 0);
		Pen Color("Green");
		Rect(0, 11, 14, 0);
	)
);
nw[AxisBox(1)] << Min(-0.1) << Max(15.1) << Inc(1);
nw[AxisBox(2)] << Min(-0.1) << Max(1.1) << Inc(1);

jthi_0-1720624128863.png

 

-Jarmo
txnelson
Super User

Re: Draw a rectangle but X and Y are in the same column

Here is a simple expansion on Jarmo's example.  I simply moved away from hardcoding the values, to using the data table values directly.

Names Default To Here( 1 );
dt = New Table( "Example",
	Add Rows( 4 ),
	New Column( "ID", Character, "Nominal", Set Values( {"1", "1", "2", "2"} ) ),
	New Column( "Parameter",
		Character,
		"Nominal",
		Set Values( {"X size", "Y size", "X size", "Y size"} )
	),
	New Column( "Value",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [10, 15, 11, 14] )
	)
);

nw = New Window( "Example",
	gb = Graph Box(
		Frame Size( 300, 300 ),
		Pen Size( 1 );
		Pen Color( "Blue" );
		Rect( 0, dt:value[2], dt:value[1], 0 );
		Pen Color( "Green" );
		Rect( 0, dt:value[4], dt:value[3], 0 );
	)
);
nw[AxisBox( 1 )] << Min( -0.1 ) << Max( 15.1 ) << Inc( 1 );
nw[AxisBox( 2 )] << Min( -0.1 ) << Max( 12.1 ) << Inc( 1 );

txnelson_0-1720625578921.png

 

Jim
Zack94
Level I

Re: Draw a rectangle but X and Y are in the same column

Thank you very much; I adapted the script to my table and it works.

 

Is there any way to do it via the graph build so that i can maybe add labels, filters, etc?

 

Thank you

jthi
Super User

Re: Draw a rectangle but X and Y are in the same column

It can be done in graph builder. How it could/should be done depends on how much are you willing to modify your data table (splitting, stacking, creating new columns, ...)?

-Jarmo
Zack94
Level I

Re: Draw a rectangle but X and Y are in the same column

Ideally leaving the table as is. I know it can be done by changing the table, as shown in the thread I linked, but I was wondering if it can be done with this kind of table structure.

txnelson
Super User

Re: Draw a rectangle but X and Y are in the same column

In your latest example of your data structure

ID Parameter Value

1   X size        10

1   Y size        15

2   X size        11

2   Y size        14

I believe you are specifying the dimensions of the rectangles to be drawn.  Where are the data points to be drawn on the Graph Builder.  The rectangles can be added to Graph Builder using <<Add Graphics Script  methodology, and the data can come from your suggested data structure, but where in your data table are the data points?

Jim