How can I use JSL to make a graph with no labels on the axes? There are a lot of reasons you might want to do this; maybe you are building a dashboard control that shows a custom picture, or maybe you have data that needs no labels.
Anyway, there are two places to look to make the labels go away – the tick mark labels (0, 10, 20, … 100) and the axis label (a variable name like Height).
Let’s use the JSL Graph Box command to create the graph like this (taken directly from the Help->Indexes->JSL Functions->Graph Box description):
New Window( "Example",
Graph Box(
Frame Size( 300, 300 ),
xaxis(show major ticks(false),show minor ticks(false),show labels(false)),
yaxis(show major ticks(false),show minor ticks(false),show labels(false)),
Marker(
Marker State( 3 ),
[11 44 77],
[75 25 50]
);
Pen Color( "Blue" );
Line( [10 30 70], [88 22 44] );
)
);

To eliminate the tick mark labels, add two commands sent to the x and y axes:
New Window( "Example",
Graph Box(
Frame Size( 300, 300 ),
xaxis(show major ticks(false),show minor ticks(false),show labels(false)),
yaxis(show major ticks(false),show minor ticks(false),show labels(false)),
Marker(
Marker State( 3 ),
[11 44 77],
[75 25 50]
);
Pen Color( "Blue" );
Line( [10 30 70], [88 22 44] );
)
);

And to eliminate the axis labels, add two more commands sent to the axes:
New Window( "Example",
g = Graph Box(
Frame Size( 300, 300 ),
xaxis(show major ticks(false),show minor ticks(false),show labels(false)),
yaxis(show major ticks(false),show minor ticks(false),show labels(false)),
Marker(
Marker State( 3 ),
[11 44 77],
[75 25 50]
);
Pen Color( "Blue" );
Line( [10 30 70], [88 22 44] );
)
);
g[axis box(1)]<
g[axis box(2)] << remove axis label;
// you could remove the tick mark labels this way, especially if you are not using the Graph Box command
// g[framebox(1)] << xaxis(show major ticks(false),show minor ticks(false),show labels(false));
// g[framebox(1)] << yaxis(show major ticks(false),show minor ticks(false),show labels(false));

(Bonus) To remove the frame as well, send four commands to the frame:
New Window( "Example",
g = Graph Box(
Frame Size( 300, 300 ),
xaxis(show major ticks(false),show minor ticks(false),show labels(false)),
yaxis(show major ticks(false),show minor ticks(false),show labels(false)),
Marker(
Marker State( 3 ),
[11 44 77],
[75 25 50]
);
Pen Color( "Blue" );
Line( [10 30 70], [88 22 44] );
)
);
g[axis box(1)] << remove axis label;
g[axis box(2)] << remove axis label;
g[frame box(1)] << left(0);
g[frame box(1)] << right(0);
g[frame box(1)] << top(0);
g[frame box(1)] << bottom(0);

Here is a complete example with a slider to make it do something:
g = Graph Box(
Frame Size( 100, 20 ),
Pen Color( "Blue" );
Y Function( 50 + 50*Sin( x*SliderValue ), x ); // graph is a sin wave, period depends on SliderValue
);
// remove adornments from graph
g[framebox( 1 )] << xaxis( show major ticks( false ), show minor ticks( false ), show labels( false ) );
g[framebox( 1 )] << yaxis( show major ticks( false ), show minor ticks( false ), show labels( false ) );
g[axis box( 1 )] << remove axis label;
g[axis box( 2 )] << remove axis label;
// hide the inner border
g[frame box( 1 )] << Left( 0 ); // no line on left, etc
g[frame box( 1 )] << Right( 0 );
g[frame box( 1 )] << top( 0 );
g[frame box( 1 )] << bottom( 0 );
// shrink and hide the outer border too
g[Border Box( 1 )] << Left( 0 ); // no space on left, etc
g[Border Box( 1 )] << Right( 0 );
g[Border Box( 1 )] << Top( 0 );
g[Border Box( 1 )] << bottom( 0 );
g[Border Box( 1 )] << sides( 0 ); // draw no sides (1+2+4+8 would be all four sides)
s = Slider Box( 0, .5, SliderValue, SliderFunction ); // slider range 0 to .5
SliderValue = .25; // initial value, becomes current value when slider is moved
SliderFunction = Function( {}, g[frame box( 1 )] << reshow ); // reshow the graph when the slider moves
// put it all together in a window
New Window( "Example",
Border Box(
Left( 10 ), Right( 10 ), top( 10 ), bottom( 10 ),
Lineup Box( N Col( 1 ), g, s )
)
);

You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.