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

Graph with two x-axes

I have a graph with two different x-axes. I would like the graph to only use the smoother and not the actual values. However, when I turn on the smoother, the values for the second axis disappear (red values). Is there a way to prevent this from happening? Please see the attached image for an example of what I am talking about. 

Graph with Two X-Axes.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Graph with two x-axes

There are also some options where you disable some of variables from different graphs

jthi_2-1681559077954.png

 

 

 

-Jarmo

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: Graph with two x-axes

I see one of two ways to get what you want.

First method is to change your data to where you have 2 columns for your Y axis.  One column for each of Ram Travel for your smoother and one for Ram Travel for your Onset time.  The Rows in the table do not overlap.  There is either data for the actual Ram Travel data or for the Ram Travel data for the offset, but not both

txnelson_0-1681402043824.png

You then create the chart with Time on the X axis, and both the Ram Travel, and Ram Travel2 for the Y axis.

The Y axis is then split into a Left and Right axis.  This will then allow you to treat the two sets of data independently.  Leaving the right axis as points and the left axis as a Smoother

txnelson_1-1681402235929.png

The second method, is to just add a Reference Line to your X axis for the Onset reference point.  If it is a static value as shown in your example chart, then this method might be a better way to handle your display

txnelson_2-1681402385435.png

 

Jim

Re: Graph with two x-axes

Shifting the one set of values to a new axis does allow for the visualization, but if I do that, then I can’t use the secondary axis for another factor. Attached is an image of the graph with a secondary factor that I already had planned on including in the graph.

 

The reference line isn’t really a good option because I have a lot of these graphs and each one has different point for the red data points. It is always a line and doesn’t change over time, but the value for it changes depending on the batch. Attached is an example of the graph with two y factors. 

Two Y Factors with Two X-Axes.jpg

txnelson
Super User

Re: Graph with two x-axes

A simple <<Add Graphics Script can be added to your graphs that will pickup the value for reference line, and then apply an <<Add Ref Line to the graph.

Jim

Re: Graph with two x-axes

I am not sure how that will work with a different value for each experiment that I am looking at. The data is all in one table and I moving between one experiment to another by using a local data filter. Is there a way to have the graph find the reference line for every single experiment and change the line based on the local data filter that I am using?

txnelson
Super User

Re: Graph with two x-axes

If you could provide some sample data I would take a look into the issue.

Jim

Re: Graph with two x-axes

I have attached an example data set. The table also includes a script to make the graph the way I am doing it now, as an example. 

txnelson
Super User

Re: Graph with two x-axes

I have been able to modify your code to display the data as a smoother and the 1st and 2nd Important times as reference lines.

txnelson_0-1681555995469.png

The JSL uses a Make Row State Handler to determine the Local Data Filter has changed, and then finds the correct 1st and 2nd Important Time data, removes the old reference lines, and then adds the new reference lines.

Names Default To Here( 1 );
dt = Current Data Table();
New Window( "filter test",
	Data Filter Context Box(
		H List Box(
			dt << Data Filter(
				Local,
				Add Filter(
					columns( :ProcessID ),
					Where( :ProcessID == "\!"0A84CE32-1054-494B-B89C-1F4780E1F760\!"" ),
					Display( :ProcessID, N Items( 15 ), Find( Set Text( "" ) ) )
				)
			),
			V List Box(
				//t = Text Box( "0 Rows Excluded" ),
				t = gb = Graph Builder(
					Size( 483, 600 ),
					Variables(
						X( :"Time Adjusted (s)"n ),
						Y( :"Ram Travel Corrected (mm)"n ),
						Y( :Other Factor, Position( 1 ), Side( "Right" ) )
					),
					Elements( Smoother( X, Y( 1 ), Legend( 8 ) ), Smoother( X, Y( 2 ), Legend( 9 ) ) ),
					Dispatch(
						{},
						"400",
						ScaleBox,
						{Legend Model(
							8,
							Properties( 0, {Line Width( 4 )}, Item ID( "Smooth(Ram Travel Corrected (mm))", 1 ) )
						), Legend Model( 9, Properties( 0, {Line Width( 4 )}, Item ID( "Smooth(Other Factor)", 1 ) ) )}
					)
				)
			)
		)
	)
);
updatetext = Function( {},
	rs = t << Get Row States();
	n = 0;
	For( ii = 1, ii <= N Rows( rs ), ii++,
		If( Excluded( As Row State( rs[ii] ) ),
			n++,
			Break();
		)
	);
	If( ii != preRefLine,
		Try( Report( gb )[AxisBox( 1 )] << Remove Ref Line( dt:"1st Important Time (s)"n[preRefLine] ) );
		Try( Report( gb )[AxisBox( 1 )] << Remove Ref Line( dt:"2nd Important Time (s)"n[preRefLine] ) );
		Report( gb )[AxisBox( 1 )] << Add Ref Line( dt:"1st Important Time (s)"n[ii], "Solid", "Orange", "", 4 );
		Report( gb )[AxisBox( 1 )] << Add Ref Line( dt:"2nd Important Time (s)"n[ii], "Solid", "Green", "", 4 );
		preRefLine = ii;
	);
);
rsupdate = Function( {a},
	If( Is Matrix( a ),
		updatetext()
	)
);
rsh = t << Make Row State Handler( dt, rsupdate );
updatetext();

 

 

Jim
jthi
Super User

Re: Graph with two x-axes

There are also some options where you disable some of variables from different graphs

jthi_2-1681559077954.png

 

 

 

-Jarmo