BookmarkSubscribe
Choose Language Hide Translation Bar
Highlighted
Thomas1
Community Trekker

Fill Color for Normal Box Plots in Graph Builder

Is there a effective way to color of or example five box plots (normal style) with fill color in graph builder by using a add-in or JSL? The five different colors should be defined via RGB values.

I don't want to use box plots with style solid, because of faded colors and missing fences. Attach a file with one colored box plot.

0 Kudos
8 REPLIES 8
cwillden
Super User

Re: Fill Color for Normal Box Plots in Graph Builder

RGB Color() seems to be what you're looking for.  For example:

 

Graph Builder(
	Size( 754, 490 ),
	Show Control Panel( 0 ),
	Variables( X( :BoxNo ), Y( :RandomVaules ), Overlay( :BoxNo ) ),
	Elements( Box Plot( X, Y, Legend( 4 ), Outliers( 0 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				4,
				Properties( 0, {Line Color( -14948892 ), Fill Color( RGB Color(100, 0, 0) )} ),
				Properties( 1, {Line Color( -3636920 )} ),
				Properties( 2, {Line Color( -5091146 )} ),
				Properties( 3, {Line Color( -9981603 )} ),
				Properties( 4, {Line Color( -16744192 )} )
			)}
		)
	)
);
-- Cameron Willden
0 Kudos
Thomas1
Community Trekker

Re: Fill Color for Normal Box Plots in Graph Builder

Thanks for your fast reply. That points in right direction. How does an JSL code in an add-in look like, in order to fill up to 5 empty boxes withe RGB colors?

0 Kudos
cwillden
Super User

Re: Fill Color for Normal Box Plots in Graph Builder

I'm not sure what you're looking for.  Do you want to have the user choose the colors in a dialog?  You want it to work for exactly 5 groups or any number of groups? The answer would vary quite a bit depending on the intended use of the add-in.

color1 = RGB Color(100,0,0);
color2 = RGB Color(50,120,50);
color3 = RGB Color(210,0,180);
color4 = RGB Color(130,130,200);
color5 = RGB Color(10,190,70);

Graph Builder(
	Size( 754, 490 ),
	Show Control Panel( 0 ),
	Variables( X( :BoxNo ), Y( :RandomVaules ), Overlay( :BoxNo ) ),
	Elements( Box Plot( X, Y, Legend( 4 ), Outliers( 0 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				4,
				Properties( 0, {Line Color( -14948892 ), Fill Color( color1 )} ),
				Properties( 1, {Line Color( -3636920 ), Fill Color( color2 )} ),
				Properties( 2, {Line Color( -5091146 ), Fill Color( color3 )} ),
				Properties( 3, {Line Color( -9981603 ), Fill Color( color4 )} ),
				Properties( 4, {Line Color( -16744192 ), Fill Color( color5 )} )
			)}
		)
	)
);
-- Cameron Willden
0 Kudos
Thomas1
Community Trekker

Re: Fill Color for Normal Box Plots in Graph Builder

I'm interested in an add-in, which I can apply on every new box plots created with the graph builder, in order to fill the boxes with the specified corporate colors.

0 Kudos
cwillden
Super User

Re: Fill Color for Normal Box Plots in Graph Builder

I'm sure it's do-able, but that's too big of a task to do for free :)

-- Cameron Willden
0 Kudos
Thomas1
Community Trekker

Re: Fill Color for Normal Box Plots in Graph Builder

Thanks for the reply. Do you have any suggestions in which direction the add-in should go?

0 Kudos
cwillden
Super User

Re: Fill Color for Normal Box Plots in Graph Builder

The tricky thing is going to be making the add-in robust to different situations.  What if someone nests 2 factors in the X drop zone?  What if there's Group X and Group Y variables?  You need to figure out at the beginning what the limitations of your add-in are going to be.

 

Then you need to kind of storyboard out an approach to the whole add-in so you can figure out what sub-tasks you will need to figure out. Here's a rough idea of what that might look like:

 

  1. Present the user with a dialog window for casting columns into specific roles for the plot.  This will act as a front end to Graph Builder
  2. When the user specifies a column for the X-axis (grouping variables), the script determines all the unique values in that column.
  3. The dialog window is updated with a lineup box containing a list of the levels of X, and dropdown boxes that allow the user to select a color for each level of X.
  4. User presses OK, which will do the following:
    • Stores all inputs into variables for execution
    • check that all required inputs are provided.  If not, return a descriptive error message
    • Build the Graph Builder script and execute it.

After you map everything out, work on 1 piece at a time.  Just make sure the pieces are going to fit together in the end.

 

-- Cameron Willden
0 Kudos
Thomas1
Community Trekker

Re: Fill Color for Normal Box Plots in Graph Builder

It can be very tricky to work with fill colors and Overlay mode in Graph Builder. If the boxes are reduced by a local data filter and one goes back to origin number of boxes, the fill color is partly disappeared.

Thats the reason why I’m interested in an add-in for fill colors.

 

May be a part solution could be helpful. In almost every case I could get or recover the fill color by adding or renewing the following JSL code.

 

SendToReport(

Dispatch(

{},

"400",

ScaleBox,

{Legend Model(

4,

Properties( 0, {Line Color( -14948892 ), Fill Color( 67 )} ),

Properties( 1, {Line Color( -3636920 ), Fill Color( 69 )} ),

Properties( 2, {Line Color( -5091146 ), Fill Color( 68 )} ),

Properties( 3, {Line Color( -9981603 ), Fill Color( 72 )} ),

Properties( 4, {Line Color( -16744192 ), Fill Color( 73 )} )

)}

)

)

 

Is there any way to build an add-in to add only this part? In this case it would be possible, to run the add-in in graph builder and to repair the fill colors.

Attached the JSL code for the uploaded file.

 

0 Kudos