Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3356404
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:30:36+00:00 2026-05-18T02:30:36+00:00

I sometimes run into the problem of labels in TreeForm being unreadable because of

  • 0

I sometimes run into the problem of labels in TreeForm being unreadable because of overlap. An example is below, can anyone see a way to get rid of overlap?

{{4, 5, 6}, {{{2, 4, 5, 6}, {{{1, 2, 4}, {}}, {{2, 3, 6}, {}}}}, {{4, 
     5, 6, 8}, {{{4, 7, 8}, {}}, {{6, 8, 9}, {}}}}}} // TreeForm


(source: yaroslavvb.com)

Belisarius’ solution helps with overlap, but loses Tooltips, ie compare with

TreeForm[Hold[
  GraphPlotHighlight[edges : {((_ -> _) | {_ -> _, _}) ...}, 
    hl : {___} : {}, opts : OptionsPattern[]] := 
   Module[{verts, coords, g, sub}, 5]]]


(source: yaroslavvb.com)

Answer update 11/12
I ended up using code below (belisarius’ code with a minor fix)

myTreeForm[exp_] := 
  Module[{tooltipText, i}, 
   tooltipText = 
    Cases[Cases[MakeBoxes[TreeForm@exp, StandardForm], 
      TooltipBox[x__] -> x, 7, Heads -> True], 
     TagBox[x__, y__] -> DisplayForm[First@{x}], Heads -> True];
   i = 0;
   TreeForm[exp, 
    VertexRenderingFunction -> ({Tooltip[
         Inset[Rasterize[Text[" " <> ToString@#2 <> " "], 
           Background -> LightBlue], #1], tooltipText[[i++]]]} &)]];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:30:36+00:00Added an answer on May 18, 2026 at 2:30 am

    I did this before, but never generalized the result.

        rectOffset = {.25,.1};
        fontSize = 10
        TreeForm[list, 
              VertexRenderingFunction -> ({White, EdgeForm[Black], 
              Rectangle[#1 - rectOffset, #1 + rectOffset], Black, 
              Text[ Style[#2, fontSize], #1]} &)]
    

    alt text

    Edit With Tooltips

    Using a “different approach”

    Code is dirty, sorry no time to clean it up right now

    rectOffset = {.33, .1};
    fontSize = 9;
    p = Cases[
       Cases[MakeBoxes[TreeForm@list, StandardForm], TooltipBox[x__] -> x,
         7, Heads -> True], TagBox[x__, y__] -> DisplayForm[First@{x}], 
       Heads -> True];
    i = 0;
    TreeForm[list, 
     VertexRenderingFunction -> ({White, EdgeForm[Black], 
         Rectangle[#1 - rectOffset, #1 + rectOffset], Black, 
         Tooltip[Text[Style[#2, fontSize], #1], p[[i++]]]} &)]  
    

    Output

    alt text

    Edit 2

    I think this version is better:

    Clear["Global`*"];
    list = Hold[
       GraphPlotHighlight[edges : {((_ -> _) | {_ -> _, _}) ...}, 
         hl : {___} : {}, opts : OptionsPattern[]] := 
        Module[{verts, coords, g, sub}, 5]];
    
    myTreeForm[exp_] :=
    
      Module[{ps, tooltipText, i},
    
       ps[text_] := Rasterize[Text[Style[text]], "RasterSize"];
    
       tooltipText = 
        Cases[Cases[MakeBoxes[TreeForm@list, StandardForm], 
          TooltipBox[x__] -> x, 7, Heads -> True], 
         TagBox[x__, y__] -> DisplayForm[First@{x}], Heads -> True];
    
       i = 0;
    
       TreeForm[list,
        EdgeRenderingFunction -> ({Red, Line[#1]} &), 
        VertexRenderingFunction -> ({White, EdgeForm[Black], {}, Black,
            Tooltip[
             Inset[Rasterize[Text[" " <> ToString@#2 <> " "], 
               Background -> LightBlue], #1], tooltipText[[i++]]]} &)]
       ];
    
    list // myTreeForm  
    

    Output:

    alt text

    Edit 4 … and last one

    Cleaned up code, remove spurious functions and variables that were there just to complicate things:

    myTreeForm[list_] := Module[{tooltipText, i},  
    
       tooltipText =   
             Cases[Cases[MakeBoxes[TreeForm@list, StandardForm],   
                        TooltipBox[x__] -> x, 7, Heads -> True],   
                  TagBox[x__, y__] -> DisplayForm[First@{x}], Heads -> True];  
       i = 0;  
       TreeForm[list,  
               VertexRenderingFunction ->  
                 ({Tooltip[Inset[Rasterize[Text[" " <> ToString@#2 <> " "], 
                           Background -> LightBlue], #1], tooltipText[[i++]]]} &) 
       ]  
     ];   
    

    HTH!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just installed VS2008 and have run into a problem that I'm sure can
It may sound stupid, but sometimes I run into version conflicts between two versions
Sometimes I get Oracle connection problems because I can't figure out which tnsnames.ora file
I run into an interesting problem while was using combos in input form. My
i’ve run into a curious problem with codeigniter's odbc driver. i’m connecting from a
I have run into a datetime related problem, my program needs to varify whether
In my ongoing experimentation with GCC inline assembly, I've run into a new problem
Boy it's annoying when you run into a problem where your code base doesn't
Greetings, I've run into a problem with a simple jQuery mousemove function: When I
Edit2: See below for new problem. I'm creating a Windows Phone 7 game and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.