cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-432398%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EGr%C3%A1fico%20de%20rect%C3%A1ngulo%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-432398%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHola%20todos%2C%3C%2FP%3E%3CP%3E%C2%BFExiste%20una%20manera%20f%C3%A1cil%20en%20JMP%20de%20generar%20un%20gr%C3%A1fico%20con%20diferentes%20rect%C3%A1ngulos%20(diferentes%20tama%C3%B1os)%3F%20Vea%20un%20ejemplo%20adjunto.%3C%2FP%3E%3CP%3ECon%20este%20gr%C3%A1fico%20me%20gustar%C3%ADa%20dar%20una%20visi%C3%B3n%20general%20de%20los%20diferentes%20materiales%20y%20sus%20formas%20correspondientes.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGracias%20por%20adelantado.%3C%2FP%3E%3CP%3EJohannes%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-432398%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3ETabla%20de%20datos%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EGr%C3%A1ficos%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-432421%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Rectangle%20Graphic%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-432421%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%C2%BFQu%C3%A9%20tipo%20de%20datos%20tienes%3F%20Puedes%20por%20ejemplo%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2Fen%2F16.1%2Findex.shtml%23page%2Fjmp%2Fcustom-map-files.shtml%23ww499781%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20crear%20archivos%20de%20formas%20personalizados%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-432425%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Rectangle%20Graphic%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-432425%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EAdjunto%20un%20archivo%20con%20datos%20de%20muestra.%20Tengo%20coordenadas%20para%20cada%20esquina%20de%20los%20rect%C3%A1ngulos.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-432567%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Rectangle%20Graphic%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-432567%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EMucha%20superposici%C3%B3n%20en%20sus%20datos.Este%20c%C3%B3digo%20lo%20har%C3%A1%3B%20Configur%C3%A9%20los%20rect%C3%A1ngulos%20sin%20relleno%20para%20mostrar%20la%20superposici%C3%B3n.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20data%20table(%22Rectangles%22)%3B%0A%0A%2F%2F%20Set%20some%20constants%0Axmin%20%3D%200%3B%0Axmax%20%3D%204000%3B%0Aymin%20%3D%200%3B%0Aymax%20%3D%201500%3B%0Axres%20%3D%20800%3B%0Ayres%20%3D%20500%3B%0A%0Acolor_list%20%20%3D%20%7B%22Red%22%2C%20%22Blue%22%2C%20%22Green%22%2C%20%22Orange%22%2C%20%22Purple%22%7D%3B%0Afilled_rect%20%3D%200%3B%20%2F%2F%20set%20to%201%20for%20filled%20rectangles%0A%0Aheat_map_win%20%3D%20New%20Window(%20%22Example%20Rectangles%20%22%2C%0A%20rect_gb%20%3D%20Graph%20Box(%0A%20%20framesize(%20xres%2C%20yres%20)%2C%0A%20%20xscale(xmin%2C%20xmax)%2C%0A%20%20yscale(ymin%2C%20ymax)%2C%0A%20%20for%20(i%20%3D%201%2C%20i%20%26lt%3B%3D%20nrows(dt)%2C%20i%2B%2B%2C%0A%20%20%20xleft%20%20%20%3D%20dt%3Ax%201%5Bi%5D%3B%0A%20%20%20xright%20%20%3D%20dt%3Ax%203%5Bi%5D%3B%0A%20%20%20ybottom%20%3D%20dt%3Ay%201%5Bi%5D%3B%0A%20%20%20ytop%20%20%20%20%3D%20dt%3Ay%204%5Bi%5D%3B%0A%20%20%20pcolor%20%20%3D%20color_list%5Bdt%3Amaterial%5Bi%5D%5D%3B%0A%20%20%20pen%20color(pcolor)%3B%0A%20%20%20fill%20color(pcolor)%3B%0A%20%20%20rect(xleft%2C%20ytop%2C%20xright%2C%20ybottom%2C%20filled_rect)%3B%0A%20%20)%2C%0A%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pmroz_0-1635947154958.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pmroz_0-1635947154958.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pmroz_0-1635947154958.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F37231i8D0F57817D43BBC3%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22pmroz_0-1635947154958.png%22%20alt%3D%22pmroz_0-1635947154958.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-432566%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Rect%C3%A1ngulo%20Gr%C3%A1fico%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-432566%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ETambi%C3%A9n%20mire%20el%20comando%20de%20transparencia%20si%20tiene%20problemas%20con%20cu%C3%A1l%20est%C3%A1%20al%20frente.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22both%20rectangles%20are%20drawn%20with%2050%25%20alpha%22%20style%3D%22width%3A%20481px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22both%20rectangles%20are%20drawn%20with%2050%25%20alpha%22%20style%3D%22width%3A%20481px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22both%20rectangles%20are%20drawn%20with%2050%25%20alpha%22%20style%3D%22width%3A%20481px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F37230iFCBD4F026D6EACA0%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Transparency.PNG%22%20alt%3D%22both%20rectangles%20are%20drawn%20with%2050%25%20alpha%22%20%2F%3E%3Cspan%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3Eboth%20rectangles%20are%20drawn%20with%2050%25%20alpha%3C%2Fspan%3E%3C%2Fspan%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3Eboth%20rectangles%20are%20drawn%20with%2050%25%20alpha%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3Eambos%20rect%C3%A1ngulos%20se%20dibujan%20con%2050%25%20alfa%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-808293%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Gr%C3%A1fico%20rectangular%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-808293%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EGracias%20por%20el%20c%C3%B3digo.%20Me%20funciona%20bien.%3C%2FP%3E%3CP%3EAhora%20me%20gustar%C3%ADa%20dividir%20los%20gr%C3%A1ficos%20por%20otra%20columna%20clave.%20Por%20ejemplo%2C%20el%20gr%C3%A1fico%201%20tendr%C3%A1%20los%20rect%C3%A1ngulos%20para%20el%20par%C3%A1metro%20A%2C%20el%20gr%C3%A1fico%202%20tendr%C3%A1%20los%20rect%C3%A1ngulos%20para%20el%20par%C3%A1metro%20B%2C%20etc.%3C%2FP%3E%3CP%3EEstoy%20teniendo%20dificultades%20para%20utilizar%20una%20cl%C3%A1usula%20Where%20o%20By%20aqu%C3%AD.%3C%2FP%3E%3CP%3ENecesitar%C3%ADa%20tener%20todos%20los%20gr%C3%A1ficos%20mostrados%20verticalmente%20y%20guardarlos%20como%20jpg.%3C%2FP%3E%3CP%3EGracias%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
JohannesENS
Level III

Rectangle Graphic

Hello everybody,

is there an easy way in JMP to generate a graph with different rectangles (different sizes)? See an example attached.

With this graph I would like to give an overview of different materials and their corresponding shapes. 

 

Thanks in advance.

Johannes

3 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Rectangle Graphic

JMP has a complete set of graphic primitives' that can be used for creating things such as rectangles.  The Scripting Index details the functions available and gives examples of their use.

txnelson_0-1635935989392.png

txnelson_1-1635936060974.png

Here is the script from the Rect() function description.

Names Default To Here( 1 );
New Window( "Example",
	Graph Box(
		Pen Color( "Green" );
		Pen Size( 2 );
		Fill Color( "Red" );
		Rect( 15, 75, 65, 55, 1 );
		Rect( 10, 80, 70, 50 );
	)
);

 

Jim

View solution in original post

pmroz
Super User

Re: Rectangle Graphic

Lots of overlap in your data.  This code will do it; I set the rectangles to unfilled to show the overlap.

dt = data table("Rectangles");

// Set some constants
xmin = 0;
xmax = 4000;
ymin = 0;
ymax = 1500;
xres = 800;
yres = 500;

color_list  = {"Red", "Blue", "Green", "Orange", "Purple"};
filled_rect = 0;	// set to 1 for filled rectangles

heat_map_win = New Window( "Example Rectangles ",
	rect_gb = Graph Box(
		framesize( xres, yres ),
		xscale(xmin, xmax),
		yscale(ymin, ymax),
		for (i = 1, i <= nrows(dt), i++,
			xleft   = dt:x 1[i];
			xright  = dt:x 3[i];
			ybottom = dt:y 1[i];
			ytop    = dt:y 4[i];
			pcolor  = color_list[dt:material[i]];
			pen color(pcolor);
			fill color(pcolor);
			rect(xleft, ytop, xright, ybottom, filled_rect);
		),
	)
);

pmroz_0-1635947154958.png

 

View solution in original post

jthi
Super User

Re: Rectangle Graphic

I would definitely do this with Graph box but you can try to do something with Graph builder also. If I understood the data correctly you have couple of different versions per material. Based  on that I did some split/stack/formulas to get table like this:

jthi_1-1635948951890.png

With this table I then created Graph builder and used smoother with confidence of fit ON.

jthi_0-1635948890277.png

 

These two happened by accident and will work only because all rectangles have "line" in x = 0:

Bar chart + line char:

jthi_4-1635949449463.png

 

Also using line with fill below:

jthi_3-1635949422438.png

 

Datatable attached with tablescript.

 

Bonus image from same data:

jthi_2-1635949405258.png

 

-Jarmo

View solution in original post

8 REPLIES 8
jthi
Super User

Re: Rectangle Graphic

 What sort of data do you have? You can for example create custom shape files

-Jarmo
JohannesENS
Level III

Re: Rectangle Graphic

I attached a file with sample data. I do have coordinates for every corner of the rectangles.

txnelson
Super User

Re: Rectangle Graphic

JMP has a complete set of graphic primitives' that can be used for creating things such as rectangles.  The Scripting Index details the functions available and gives examples of their use.

txnelson_0-1635935989392.png

txnelson_1-1635936060974.png

Here is the script from the Rect() function description.

Names Default To Here( 1 );
New Window( "Example",
	Graph Box(
		Pen Color( "Green" );
		Pen Size( 2 );
		Fill Color( "Red" );
		Rect( 15, 75, 65, 55, 1 );
		Rect( 10, 80, 70, 50 );
	)
);

 

Jim
JohannesENS
Level III

Re: Rectangle Graphic

Thank you!

Craige_Hales
Super User

Re: Rectangle Graphic

Also look at the transparency command if you have issues with which one is in front.

 

both rectangles are drawn with 50% alphaboth rectangles are drawn with 50% alpha

Craige
pmroz
Super User

Re: Rectangle Graphic

Lots of overlap in your data.  This code will do it; I set the rectangles to unfilled to show the overlap.

dt = data table("Rectangles");

// Set some constants
xmin = 0;
xmax = 4000;
ymin = 0;
ymax = 1500;
xres = 800;
yres = 500;

color_list  = {"Red", "Blue", "Green", "Orange", "Purple"};
filled_rect = 0;	// set to 1 for filled rectangles

heat_map_win = New Window( "Example Rectangles ",
	rect_gb = Graph Box(
		framesize( xres, yres ),
		xscale(xmin, xmax),
		yscale(ymin, ymax),
		for (i = 1, i <= nrows(dt), i++,
			xleft   = dt:x 1[i];
			xright  = dt:x 3[i];
			ybottom = dt:y 1[i];
			ytop    = dt:y 4[i];
			pcolor  = color_list[dt:material[i]];
			pen color(pcolor);
			fill color(pcolor);
			rect(xleft, ytop, xright, ybottom, filled_rect);
		),
	)
);

pmroz_0-1635947154958.png

 

LargeElk892
Level II

Re: Rectangle Graphic

Thanks for the code. Working well for me.

Now I'd like to split the graphs by another key column. E.g. graph 1 will have the  rectangles for parameter A, graph 2 will have the  rectangles for parameter B, etc.

I'm struggling to use a Where or By clause here.

I would need to have all the graphs displayed vertically and save it as a jpg.

Thank you

jthi
Super User

Re: Rectangle Graphic

I would definitely do this with Graph box but you can try to do something with Graph builder also. If I understood the data correctly you have couple of different versions per material. Based  on that I did some split/stack/formulas to get table like this:

jthi_1-1635948951890.png

With this table I then created Graph builder and used smoother with confidence of fit ON.

jthi_0-1635948890277.png

 

These two happened by accident and will work only because all rectangles have "line" in x = 0:

Bar chart + line char:

jthi_4-1635949449463.png

 

Also using line with fill below:

jthi_3-1635949422438.png

 

Datatable attached with tablescript.

 

Bonus image from same data:

jthi_2-1635949405258.png

 

-Jarmo

Recommended Articles