Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- wrap axis lables

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 18, 2012 5:46 AM
(6397 views)

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

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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**;

nextspace;

While**(** ns >= wrap,

col**[]** = Munger**(** col**[]**, wrap * n, " ", "\!n" **)**;

n++;

nextspace;

**)**;

**)**;

// Decrease axisbox width

Report**(** gb **)[**AxisBox**(** **2** **)]** << set width**(** **30** **)**; //Does not work!

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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**;

nextspace;

While**(** ns >= wrap,

col**[]** = Munger**(** col**[]**, wrap * n, " ", "\!n" **)**;

n++;

nextspace;

**)**;

**)**;

// Decrease axisbox width

Report**(** gb **)[**AxisBox**(** **2** **)]** << set width**(** **30** **)**; //Does not work!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: wrap axis lables

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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: wrap axis lables

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...)

//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, " " **)** **)**;

For Each Row**(**

n = **1**;

nextspace;

While**(** ns >= wrap,

col**[]** = Munger**(** col**[]**, wrap * n, " ", "\!n" **)**;

n++;

nextspace;

**)**;

**)**;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: wrap axis lables

thanks!

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!!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: wrap axis lables

I can't seem to get this to work... has anyone had any luck with wrapping axis labels in graphs? I'm using JMP 13.1.0

Thanks!