hi all,
does anyone know how to wrap long labels of an axis in the graph builder? i have a very long variable name and it makes the graphs completely disproportionate as in the picture
thanks,
ron
I can't find a direct way to wrap labels within the graphbuilder platform. One trick is to use linefeeds in the label names, i.e. in the table cell content.
I tried to automate that with jsl and it seem to work. But the graph still looks quite disproportionate because the width of the axis box does not change with width of the label and I haven't found a way that works to do that (manually or by script). See script and result below.
//Example table
dt =New Table( "example.jmp",
Add Rows( 3 ),
New Column( "Label", Character, Nominal,
Set Values(
{"This is a very long label that I wish could be wrapped", "Somewhat too long label",
"A perfect label"}
)
),
New Column( "Data", Numeric, Continuous, Format( "Best", 12 ), Set Values( [5, 8, 2] ) )
);
// Example graph
gb = Graph Builder( Variables( Y( :Label ), X( :Data ) ), Elements( Bar( X, Y ) ) );
wrap = 15; // Select desired witdth
// Insert linefeeds at not too close spaces
col = Column( dt, "Label" );
nextspace = expr(ns=Munger( col[], wrap * n, " " ));
nextspace;
For Each Row(
n = 1;
While( ns >= wrap,
col[] = Munger( col[], wrap * n, " ", "\!n" );
n++;
// Decrease axisbox width
Report( gb )[AxisBox( 2 )] << set width( 30 ); //Does not work!
thanks MS,
I ran the script but it didn't reproduce the plot in the picture. in the log i get the following:
Name Unresolved: n{3} in access or evaluation of 'n' , n
thanks!
It works in JMP 10 (Mac) but if I try in JMP 9 I get the same error as you. Something's changed.
esit: now I found the error: There is a redundant "nextspace" evaluation right before ForEach Loop() that includes a not-yet defined n. For some reason JMP 10 did not complain.
This works both in JMP 9 and 10:
(There is probably a more elegant way...)
dt = New Table( "example.jmp",
New Column( "Label",
Character,
Nominal,
nextspace = Expr( ns = Munger( col[], wrap * n, " " ) );
i am actually using JMP 10 for windows.
now i do not get the error message but also can't get the wrapped plot.
many thanks!!!