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

Graph builder with separate overlay, color and marker

legend-requirement.png

I am trying to use JSL to construct a plot similar to the one shown above. My attempt is below. Where I am stuck is that I don't want the marker legend to use the overlay variable, but to use lgd2. The solution needs to work for various number of categories for "lgd1" and "lgd2".

dt = New Table( "example",
	Add Rows( 18 ),
	Set Header Height( 60 ),
	New Column( "lgd1",
		Character,
		"Nominal",
		Set Values(
			{"A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "C", "C",
			"C", "C", "C", "C"}
		),
		Set Display Width( 63 )
	),
	New Column( "lgd2",
		Numeric,
		"Nominal",
		Format( "Best", 12 ),
		Set Values( [1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2] )
	),
	New Column( "value",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 1, 2, 1.5, 1.5, 2, 2, 2, 3, 2, 4, 3, 4, 4.5, 5, 4, 6, 5.5] )
	),
	New Column( "X",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3] )
	),
	New Column( "Group",
		Character,
		"Nominal",
		Set Values(
			{"A-1", "A-1", "A-1", "A-2", "A-2", "A-2", "B-1", "B-1", "B-1", "B-2",
			"B-2", "B-2", "C-1", "C-1", "C-1", "C-2", "C-2", "C-2"}
		)
	)
);


DT << Graph Builder(
	Size( 500, 500 ),
	Show Control Panel( 0 ),
	Fit to Window( "Off" ),
	Variables( X( :X ), Y( :value ), Overlay( :Group ), Color( :lgd1 ) ),
	Elements( Line( X, Y, Legend( 1 ) ), Points( X, Y, Legend( 2 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				1,
				Properties( 0, {Marker Size( 5 )}, Item ID( "A", 1 ) ),
				Properties( 1, {Marker Size( 5 )}, Item ID( "B", 1 ) )
			), Legend Model(
				2,
				Properties( 3, {Marker Size( 5 )}, Item ID( "A-1", 1 ) ),
				Properties( 4, {Marker Size( 5 )}, Item ID( "A-2", 1 ) ),
				Properties(
					5,
					{Marker( "Circle" ), Marker Size( 5 )},
					Item ID( "B-1", 1 )
				),
				Properties(
					6,
					{Marker( "Plus" ), Marker Size( 5 )},
					Item ID( "B-2", 1 )
				),
				Properties(
					7,
					{Marker( "Circle" ), Marker Size( 5 )},
					Item ID( "C-1", 1 )
				),
				Properties(
					8,
					{Marker( "Plus" ), Marker Size( 5 )},
					Item ID( "C-2", 1 )
				)
			)}
		),
		Dispatch(
			{},
			"400",
			LegendBox,
			{Legend Position( {1, [0, 1, 2], 2, [-1, -1, -1, 3, 4, 5, 6, 7, 8]} ),
			Position( {0, 1, 2, -1, -1, -1, 3, 4, 5, 6, 7, 8} )}
		)
	)
);

 

2 REPLIES 2
Thierry_S
Super User

Re: Graph builder with separate overlay, color and marker

Hi, 

Just a quick note that may (perhaps) meet your requirements if you do not mind a bit of manual preparation:

  1. Create 2 new columns by splitting Group column (Column > Text to Column  > Separator = "-".
  2. If you want, rename the column as CLASS and SUBCLASS, respectively
  3. Assign Symbols to each row based on the SUBCLASS column (No Color, Symbols = Standard)
  4. Build your plot with Overlay = Group, and Color as CLASS
  5. Under the Points menu, deactivate the Overlay option (as shown below)

 

Thierry_S_2-1617688320591.png

There is another manual option where you will not need to assign the Markers and switch-off the Overlay under Points: in the Preferences > Graphs > Graph Marker Theme > Paired will yield something similar to what you may need.

Best,

TS

 

 

Thierry R. Sornasse
Mittman
Level III

Re: Graph builder with separate overlay, color and marker

Thanks, @Thierry_S . I've edited my original post to include more details on the required solution.