1
$\begingroup$

I start with a list of occupation titles:

OccTitlerules = {"Carpenters" -> "Sheet Metal Workers", 
 "Cement Masons and Concrete Finishers" -> "Carpenters", 
 "Construction Laborers" -> "Helpers--Carpenters", 
 "Construction Managers" -> "Cost Estimators", 
 "Cost Estimators" -> "Construction Managers", 
 "Electricians" -> 
  "Heating, Air Conditioning, and Refrigeration Mechanics and 
Installers", 
 "Fence Erectors" -> 
  "Helpers--Brickmasons, Blockmasons, Stonemasons, and Tile and 
Marble Setters", 
 "First-Line Supervisors of Construction Trades and Extraction 
Workers" -> 
  "First-Line Supervisors of Mechanics, Installers, and Repairers", 
 "First-Line Supervisors of Mechanics, Installers, and Repairers" -> 
  "First-Line Supervisors of Construction Trades and Extraction 
Workers", 
 "Heating, Air Conditioning, and Refrigeration Mechanics and 
Installers" -> "Electricians", 
 "Helpers--Brickmasons, Blockmasons, Stonemasons, and Tile and Marble 
Setters" -> "Cement Masons and Concrete Finishers", 
 "Helpers--Carpenters" -> "Construction Laborers", 
 "Helpers--Electricians" -> "Helpers--Carpenters", 
 "Helpers--Pipelayers, Plumbers, Pipefitters, and Steamfitters" -> 
  "Construction Laborers", 
 "Insulation Workers, Mechanical" -> "Roofers", 
 "Plumbers, Pipefitters, and Steamfitters" -> "Electricians", 
 "Roofers" -> "Insulation Workers, Mechanical", 
 "Sheet Metal Workers" -> "Carpenters"};

Then I build the following Layered Graph Plot:

LayeredGraphPlot[OccTitlerules, Bottom, VertexLabeling -> True, 
 BaseStyle -> {FontSize -> 12}, ImageSize -> 2600, AspectRatio -> 1/2]

Notice that I have to use a large ImageSize value because; otherwise, some of the labels contained in the text boxes will overlap. Unfortunately; doing this makes the plot so large that I'm unable to print it in regular 8.5" X 11" paper.

I cannot abbreviate the job titles because they are specific are necessary.

My question is; is there a way to "wrap" the text so that the longest job titles are better disbursed inside their text boxes?

For example; the job title:

"Air Conditioning, and Refrigeration Mechanics and Installers"

with text wrapping applied to it becomes:

"Air Conditioning, and Refrigeration

Mechanics and Installers"

Thank you!

$\endgroup$
  • $\begingroup$ you could use \n where you want your text to go to the next line, so "Air Conditioning, and Refrigeration \nMechanics and Installers" would give you the desired output. $\endgroup$ – J_Nat Aug 4 '16 at 14:54
  • $\begingroup$ Or try something like this under VertexRenderingFunction: mathematica.stackexchange.com/questions/15250/… $\endgroup$ – J_Nat Aug 4 '16 at 15:18
3
$\begingroup$

You could add Pane around your text:

LayeredGraphPlot[
 Map[Pane[Tooltip[#, #], ImageSize -> {65, 30}, 
    ImageSizeAction -> "ShrinkToFit"] &, OccTitlerules, {2}], Bottom, 
 VertexLabeling -> True, BaseStyle -> {FontSize -> 12, Bold}, 
 AspectRatio -> 1/2, ImageSize -> 900]

enter image description here

$\endgroup$
  • $\begingroup$ It is a pity that the text entries get so distorted inside the boxes but, beggars can't be choosers! This will give me something extra "to fiddle about with" until I reach what I need. THANK YOU! $\endgroup$ – Gilmar Rodriguez Pierluissi Aug 5 '16 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.