cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
mvanderaa1
Level IV

How to change all box plot confidence diamonds colors in graph builder?

Hi, I want to have the confidence level color black for all my box plots in graph builder. See below example of the monthly sales datatable. I'm using the "Month" column as coloring variable, but my confidence diamonds are not visible as they have the same color as the box plots.

 

mvanderaa1_0-1651149503629.png

 

I tried to add a loop to set the line color to black, but this changes the box plot colors to gray

gb = Graph Builder(
	Size( 1805, 897 ),
	Show Control Panel( 0 ),
	Variables( X( :Month ), Y( :Sales ), Color( :Month ) ),
	Elements(
		Box Plot(
			X,
			Y,
			Legend( 9 ),
			Box Style( "Solid" ),
			Confidence Diamond( 1 ),
			Fences( 0 )
		)
	)
);
//tried the method of changing the confidence level line color to black for each box plot, 
//but it removes all pre-existing colors 
bpseg = gb << Xpath( "//BoxPlotSeg" );
bpseg << Line Color (0);

mvanderaa1_1-1651149604528.png

Attached is also the datatable, any help would be appreciated

1 REPLY 1
txnelson
Super User

Re: How to change all box plot confidence diamonds colors in graph builder?

I was able to accomplish what you want by makinf a couple of changes to your approach.

txnelson_0-1651155116661.png

 

  1. Create your chart, but do not select Confidence Diamonds
  2. Right click on the chart and select Add=>Box Plot, to add a second Box Plot
  3. In the variables for the 2nd Box Plot, expand the section and unselect Color Month
  4. Now Right Click on the chart and select the 2nd Box Plot and select Confidence Diamonds
  5. Finally, go to the legend and Right Click the Sales and change the Line Color to black 

Here is the script from the chart

Names Default To Here( 1 );
dt = Current Data Table();

Graph Builder(
	Variables( X( :Month ), Y( :Sales ), Color( :Month ) ),
	Elements(
		Box Plot( X, Y, Legend( 4 ), Box Style( "Solid" ), Fences( 0 ) ),
		Box Plot( X, Y, Color( 0 ), Legend( 5 ), Confidence Diamond( 1 ) )
	),
	SendToReport(
		Dispatch( {"Box Plot"[2]}, "", OutlineBox, {Close( 0 )} ),
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				5,
				Properties( 0, {Line Color( 0 )}, Item ID( "Sales", 1 ) )
			)}
		)
	)
);
Jim