Difference between revisions of "Template:Clade/doc/common"

From blackwiki
Jump to navigation Jump to search
imported>Jts1882
(add graphical summary section)
imported>Peter coxhead
(content has been copied from this subpage (which is no longer needed) to the parent page, so redirect for now)
 
Line 1: Line 1:
<includeonly>==Basic features==
+
#REDIRECT[[Template:Clade/doc]]
 
 
===Usage===
 
 
 
<pre>
 
<nowiki>
 
{{clade
 
|label1=Base
 
|1=Node
 
}}</nowiki>
 
</pre>
 
 
 
produces
 
{{clade
 
|label1=Base
 
|1=Node
 
}}
 
 
 
<pre>
 
<nowiki>
 
{{clade
 
|1={{clade
 
  |label1=[[Subtree1]]
 
  |1=Leaf1
 
  |label2=Subtree2
 
  |2=[[Leaf2]]
 
  }}
 
}}</nowiki>
 
</pre>
 
 
 
produces
 
{{clade
 
|1={{clade
 
  |label1=[[Subtree1]]&nbsp;
 
  |1=Leaf1
 
  |label2=Subtree2&nbsp;
 
  |2=[[Leaf2]]
 
  }}
 
}}
 
 
 
<pre>
 
<nowiki>
 
{{clade| style=font-size:75%;line-height:75%;
 
|1={{clade
 
  |label1=Subtree1
 
  |1=Leaf1
 
  |label2=Subtree2
 
  |2=Leaf2
 
  }}
 
}}</nowiki>
 
</pre>
 
 
 
produces
 
{{clade| style=font-size:75%;line-height:75%;
 
|1={{clade
 
  |label1=Subtree1
 
  |1=Leaf1
 
  |label2=Subtree2
 
  |2=Leaf2
 
  }}
 
}}
 
 
 
Note that the order of the parameters does not matter. Exactly the same output is produced by
 
<pre>
 
<nowiki>
 
{{clade| style=font-size:75%;line-height:75%;
 
|1={{clade
 
  |2=Leaf2
 
  |1=Leaf1
 
  |label1=Subtree1
 
  |label2=Subtree2
 
  }}
 
}}</nowiki>
 
</pre>
 
 
 
{{clade| style=font-size:75%;line-height:75%;
 
|1={{clade
 
  |1=Leaf1
 
  |2=Leaf2
 
  |label2=Subtree2
 
  |label1=Subtree1
 
  }}
 
}}
 
 
 
 
 
===Styling brackets and branches===
 
 
 
{| class="wikitable"
 
!Description
 
!Template code
 
!Resulting output
 
|-
 
| style="width:25%;vertical-align:top;" | '''Styling brackets'''
 
 
 
The thickness, colour and state (solid, dashed, etc) of bracket lines can be changed using the <code>thickness=</code>, <code>|color=</code> and <code>|state=</code> parameters.
 
 
 
|<pre>
 
<nowiki>
 
{{clade
 
  |label1=Bracket styling
 
  |sublabel1=(no suffix)
 
  |style1x=background-color:#ffffee;
 
  |1={{Clade
 
      |label2=color
 
      |2={{Clade |color=red
 
        |1=A
 
        |2=B               
 
        |3=C           
 
        }}
 
      |label1=thickness
 
      |1={{Clade |thickness=3
 
          |1=I 
 
          |2=J         
 
          |3=K           
 
          }}
 
      |label3=state
 
      |3={{Clade |state=dashed
 
        |1=X
 
        |2=Y       
 
        |3=Z       
 
 
        }}
 
      }}
 
}}
 
 
 
</nowiki>
 
</pre>
 
 
 
|
 
{{clade
 
  |label1=Bracket styling
 
  |sublabel1=(no suffix)
 
  |style1x=background-color:#ffffee;
 
  |1={{Clade
 
      |label2=color
 
      |2={{Clade |color=red
 
        |1=A
 
        |2=B               
 
        |3=C           
 
        }}
 
      |label1=thickness
 
      |1={{Clade |thickness=3
 
          |1=I 
 
          |2=J         
 
          |3=K           
 
          }}
 
      |label3=state
 
      |3={{Clade |state=dashed
 
        |1=X
 
        |2=Y       
 
        |3=Z       
 
 
        }}
 
      }}
 
}}
 
 
 
|-
 
| style="width:25%;vertical-align:top;" |'''Styling individual branches'''
 
 
 
The thickness, colour and state of individual branch lines can be changed using the <code>thicknessN=</code>, <code>|colorN=</code> and <code>|stateN=</code> parameters, where N is the number of the branch to be styled.
 
 
 
|<pre>
 
<nowiki>
 
{{clade
 
  |label1=Branch styling
 
  |sublabel1=(append branch number)
 
  |style1x=background-color:#eeeeee;
 
  |1={{Clade
 
      |label2=colorN
 
      |2={{Clade
 
        |1=black (default) |color1=black         
 
        |2=red            |color2=red   
 
        |3=blue            |color3=blue 
 
        |4=&nbsp;#00ff00      |color4=#00ff00 
 
        }}
 
      |label1=thicknessN
 
      |1={{Clade
 
          |1=1 (default) |thickness1=1
 
          |2=2          |thickness2=2
 
          |3=3          |thickness3=3 
 
          }}
 
      |label3=stateN
 
      |3={{Clade
 
        |1=solid (default) |state1=solid 
 
        |2=dotted          |state2=dotted 
 
        |3=dashed          |state3=dashed
 
        |4=none            |state4=none 
 
        |5=double          |state5=double
 
        }}
 
      }}
 
}}
 
 
 
</nowiki>
 
</pre>
 
 
 
 
 
|
 
{{clade
 
  |label1=Branch styling
 
  |sublabel1=(append branch number)
 
  |style1x=background-color:#eeeeee;
 
  |1={{Clade
 
      |label2=colorN
 
      |2={{Clade
 
        |1=black (default) |color1=black         
 
        |2=red            |color2=red   
 
        |3=blue            |color3=blue 
 
        |4=&nbsp;#00ff00      |color4=#00ff00 
 
        }}
 
      |label1=thicknessN
 
      |1={{Clade
 
          |1=1 (default) |thickness1=1
 
          |2=2          |thickness2=2
 
          |3=3          |thickness3=3 
 
          }}
 
      |label3=stateN
 
      |3={{Clade
 
        |1=solid (default) |state1=solid 
 
        |2=dotted          |state2=dotted 
 
        |3=dashed          |state3=dashed
 
        |4=none            |state4=none 
 
        |5=double          |state5=double
 
        }}
 
      }}
 
}}
 
|}
 
 
 
===Tips===
 
 
 
An easy way of creating larger cladograms is to use the Newick format and proceed to edit it using a suitable text editor to produce the markup.
 
 
 
# Start with [[Newick format]] ((a,b),(c,d))
 
# Replace "(" with <nowiki>"{{clade|"</nowiki>
 
# Replace ")" with <nowiki>"}}"</nowiki>
 
# Edit to replace commas with pipes and numbers
 
# Edit clade labels if needed
 
 
 
Alternatively, one can easily generate required clade code by downloading the free Windows utility, 'Claded', via link at http://code.google.com/p/claded, 'Claded' allowing editing of Cladograms using a tree control.
 
 
 
<pre>
 
<nowiki>
 
{{clade
 
|1={{clade
 
    |1=a
 
    |2=b
 
    }}
 
|2={{clade
 
    |1=c
 
    |2=d
 
    }}
 
}}
 
</nowiki>
 
</pre>
 
 
 
Example Perl script to automate the conversion:
 
<source lang="perl">
 
use constant N=>"\n";
 
use constant T=>"\t";
 
 
 
my $tree='((a,b),(c,d));'; # get sequence
 
$tree=~s/[\n\r]//g; # loose those spaces
 
$tree=~ s/\:[\.\d]+//g; # loose those lengths
 
while ($tree=~ m/\(/) {
 
foreach my $clade ($tree=~ m/\(([^\(\)]+)\)/g) {
 
my @branches=split /\,/,$clade;
 
s/(\t+)/$1\t/g for @branches;
 
die 'ERROR: degenerate/empty node!'.N if $#branches<1;
 
$tree=~ s/\(\Q$clade\E\)/${\join('','{{clade',N,map(T.'|'.($_+1).'='.$branches[$_].N,0..$#branches),T.'}}')}/; # substitute
 
}
 
pos($tree)=0;
 
}
 
$tree=~s/(\t*)\t\}\}/$1\}\}/g; # lazy fix
 
 
 
print $tree;
 
</source>
 
 
 
==Using a box==
 
 
 
You can nest the templates and use links around the text. You may use non-breaking spaces (&amp;nbsp;) to obtain spaces or to have labels that have spaces.
 
 
 
The entire cladogram can be placed in a box so that text flows nicely around it. You can use {{tl|Cladogram}} to produce the box.
 
{{cladogram|title=Example
 
|caption=Sample of {{tl|Cladogram}}
 
|clades={{clade| style=font-size:75%;line-height:75%;
 
    |label1=[[Neornithes]]&nbsp;&nbsp;
 
    |1={{clade
 
        |label1=[[Paleognathae]]
 
        |1=&nbsp;
 
        |label2=&nbsp;[[Neognathae]]&nbsp;
 
        |2={{clade
 
            |1=Other birds
 
            |label1=&nbsp;
 
            |label2=[[Galloanserae]]&nbsp;
 
            |2={{clade
 
                |1=[[Anseriformes]]
 
                |label2=&nbsp;&nbsp;&nbsp;&nbsp;
 
                |2={{clade
 
                    |1=[[Galliformes]]
 
                    |2=[[Craciformes]]
 
                    }}
 
                }}
 
            }}
 
        }}
 
    }}
 
}}
 
<pre>
 
{{cladogram|title=Example
 
|caption=Sample of {{tl|Cladogram}}
 
|clades={{clade| style=font-size:75%;line-height:75%;
 
    |label1=[[Neornithes]]&nbsp;&nbsp;
 
    |1={{clade
 
        |label1=[[Paleognathae]]
 
        |1=&nbsp;
 
        |label2=&nbsp;[[Neognathae]]&nbsp;
 
        |2={{clade
 
            |1=Other birds
 
            |label1=&nbsp;
 
            |label2=[[Galloanserae]]&nbsp;
 
            |2={{clade
 
                |1=[[Anseriformes]]
 
                |label2=&nbsp;&nbsp;&nbsp;&nbsp;
 
                |2={{clade
 
                    |1=[[Galliformes]]
 
                    |2=[[Craciformes]]
 
                    }}
 
                }}
 
            }}
 
        }}
 
    }}
 
}}
 
</pre>
 
 
 
==Controlling the layout of sisters==
 
 
 
When one sister is represented as a leaf node and the other as a labelled subclade, they do not appear to be at the same level. Consider this cladogram:
 
{{clade
 
|1={{clade
 
  |1=[[Banksia subser. Sphaerocarpae|''Banksia''&nbsp;subser.&nbsp;''Sphaerocarpae'']] (5 taxa)
 
  |label2=[[Banksia subser. Leptophyllae|''Banksia''&nbsp;subser.&nbsp;''Leptophyllae'']]
 
  |2={{clade
 
      |1=''[[Banksia telmatiaea]]''
 
      |2=(4 other taxa)
 
      }}
 
  }}
 
}}
 
Although ''Banksia''&nbsp;subser.&nbsp;''Sphaerocarpae'' and ''Banksia''&nbsp;subser.&nbsp;''Leptophyllae'' are sisters, their names are not aligned in the cladogram. If this is considered undesirable, one solution is to use a label in both cases, as shown hereafter, which now shows the sisters at the same level.
 
{{clade
 
|1={{clade
 
  |label1=[[Banksia subser. Sphaerocarpae|''Banksia''&nbsp;subser.&nbsp;''Sphaerocarpae'']]<!--added label, moved from leaf below-->
 
  |1=(5 taxa)
 
  |label2=[[Banksia subser. Leptophyllae|''Banksia''&nbsp;subser.&nbsp;''Leptophyllae'']]
 
  |2={{clade
 
      |1=''[[Banksia telmatiaea]]''
 
      |2=(4 other taxa)
 
      }}
 
  }}
 
}}
 
Another 'trick' is to introduce a dummy clade. The dotted line hereafter shows where an extra clade has been inserted:
 
{{clade
 
|1={{clade
 
  |1=[[Banksia subser. Sphaerocarpae|''Banksia''&nbsp;subser.&nbsp;''Sphaerocarpae'']] (5 taxa)
 
  |2={{clade<!--dummy-->
 
      |label1=[[Banksia subser. Leptophyllae|''Banksia''&nbsp;subser.&nbsp;''Leptophyllae'']]<!--moved from 2 to 1 in new clade-->
 
        |1={{clade
 
        |1=''[[Banksia telmatiaea]]''
 
        |2=(4 other taxa)
 
        }}
 
      }}
 
  }}
 
}}
 
 
 
To achieve this, instead of
 
<pre>
 
{{clade
 
|1=Sister1
 
|label2=Sister2
 
|2={{clade
 
  |1=taxon1
 
  |2=taxon2}}
 
}}
 
</pre>
 
which displays as:
 
{{clade
 
|1=Sister1
 
|label2=Sister2
 
|2={{clade
 
  |1=taxon1
 
  |2=taxon2}}
 
}}
 
use
 
<pre>
 
{{clade
 
|1=Sister1
 
''|2={{clade'' (extra ''dummy'' clade)
 
  |label1=Sister2
 
    |1={{clade
 
      |1=taxon1
 
      |2=taxon2}}
 
  }}
 
}}
 
</pre>
 
which displays as:
 
{{clade
 
|1=Sister1
 
|2={{clade
 
  |label1=Sister2
 
    |1={{clade
 
      |1=taxon1
 
      |2=taxon2}}
 
  }}
 
}}
 
 
 
<!--  ===== FOR cladex ONLY:
 
 
 
-->{{#ifeq:{{{1|}}}|cladex|
 
==Bracketting nodes==
 
 
 
To insert a coloured 'bracket' around a set of leaf nodes which follow one another in the generated cladogram:
 
* Add <code>barbeginN=''colour''</code> for the first leaf node, where N is the order of that leaf node within its clade, and ''colour'' is the required colour.
 
* Add <code>barN=''colour''</code> for the remaining nodes other than the last (note that N must be the order of that node within its clade).
 
* Add <code>barendN=''colour''</code> for the last node.
 
 
 
<code>{{!}}style=width:auto</code> must be present.
 
 
 
<pre>
 
<nowiki>
 
{{clade|style=font-size:85%;line-height:100%;
 
|1={{clade
 
  |1=Leaf A
 
  |2=Leaf B|barbegin2=green
 
  |3=Leaf C|bar3=green
 
  |4={{clade
 
      |1=Leaf D|barend1=green
 
      |2=Leaf E
 
      |3=Leaf F|barbegin3=purple
 
      |4={{clade
 
        |1=Leaf G|bar1=purple
 
        |2=Leaf H|barend2=purple
 
        }}
 
      }}
 
  }}
 
}}
 
</nowiki>
 
</pre>
 
 
 
produces
 
{{clade|style=font-size:85%;line-height:100%;
 
|1={{clade
 
  |1=Leaf A
 
  |2=Leaf B|barbegin2=green
 
  |3=Leaf C|bar3=green
 
  |4={{clade
 
      |1=Leaf D|barend1=green
 
      |2=Leaf E
 
      |3=Leaf F|barbegin3=purple
 
      |4={{clade
 
        |1=Leaf G|bar1=purple
 
        |2=Leaf H|barend2=purple
 
        }}
 
      }}
 
  }}
 
}}
 
 
 
The horizontal lines can be omitted by using <code>{{!}}barN=''colour''</code> throughout. Thus the following (note the use of <code>{{!}}style=width:auto</code>):
 
 
 
<pre>
 
<nowiki>
 
{{clade|style=width:auto;font-size:85%;line-height:100%;
 
|1=Leaf A
 
|2={{clade
 
  |1=Leaf B|bar1=midnightblue
 
  |2=Leaf C|bar2=midnightblue
 
  }}
 
|3=Leaf D|bar3=midnightblue
 
}}</nowiki>
 
</pre>
 
 
 
produces
 
{{clade|style=width:auto;font-size:85%;line-height:100%;
 
|1=Leaf A
 
|2={{clade
 
  |1=Leaf B|bar1=midnightblue
 
  |2=Leaf C|bar2=midnightblue
 
  }}
 
|3=Leaf D|bar3=midnightblue
 
}}
 
 
 
''Note that brackets or bars must only be applied to leaf nodes.'' In the preceding example, it may be tempting to write
 
 
 
<pre>
 
<nowiki>
 
{{clade|style=width:auto;font-size:85%;line-height:100%;
 
|1=Leaf A
 
|bar2=midnightblue
 
|2={{clade
 
  |1=Leaf B
 
  |2=Leaf C
 
  }}
 
|3=Leaf D|bar3=midnightblue
 
}}</nowiki>
 
</pre>
 
 
 
with the expectation that the bar will be to the right of the whole of the clade containing Leaf B and Leaf C. This does not produce the required output.
 
 
 
===Specifying colours===
 
 
 
You can use any of the ways in which colours can be specified in [[HTML]]; e.g. the standard [http://www.w3schools.com/html/html_colornames.asp colour names], the three or six hex digit notations, such as #FC3 or #F3C630, or the <code>rgb()</code> notation.
 
 
 
===Supplying text labels===
 
 
 
Text labels for each bracket/bar can be added using {{tl|Barlabel}}. Accessibility guidelines require pages not to rely on colour alone, so it's particularly important to add labels if you have more than one bracket/bar and need to refer to them separately.
 
 
 
===Debugging===
 
 
 
If your cladogram doesn't display brackets/bars as you expected, check that:
 
* You understand the numbering system for the parameters <code>barN</code>, etc. The N must be the same as the number of the child within its clade. Thus typically you should write <code>{{!}}N=''label for leaf''{{!}}barN=''colour for bar''</code>, e.g. <code>{{!}}2=<nowiki>[[Passeridae]]</nowiki>{{!}}bar2=midnightblue</code>.
 
* You have only attempted to apply brackets/bars to ''leaf'' nodes.
 
<!--
 
      ===== END OF FOR cladex ONLY-->
 
 
 
==Limitations==
 
 
 
===Label length===
 
Labels produced by <code>|labelN=</code>, where <code>N</code> is 1, 2, ..., can lead to poor layout of the resulting cladogram. (This does not apply to the text of leaves, i.e. text produced by <code>|N=</code>.) To avoid problems:
 
* Labels should be kept as short as possible, ideally a single word
 
* Any necessary spaces in labels should be represented as &amp;nbsp; not as actual spaces.
 
* Line breaks (i.e. <nowiki><br/></nowiki>) should not be used.
 
 
 
===Browser differences===
 
 
 
[[File:Cladograms - browser variation.png|thumb|Browser variation: left – most browsers; right – Safari
 
]]
 
 
 
Cladograms are drawn by generating hidden tables. The horizontal and vertical lines making up the tree are actually the edges of table cells. The tables are then drawn by the browser or user agent using its internal algorithms. As these differ from browser to browser, the trees produced will not look the same on all browsers.
 
 
 
In particular, {{as of|2017|January|lc=yes}}, there are two algorithms for laying out tables with empty cells, used by two groups of browsers. Most browsers now use the algorithm that produces cladograms like the two on the left in the diagram. Safari (under both MacOS and iOS) uses another algorithm, producing cladograms like the two on the right in the diagram.
 
 
 
No automated "fix" for these differences exists at present.
 
 
 
If there is a choice over the ordering of the terminal nodes (leaves) of the tree, cladograms look best in a Safari-like browser if as much branching as possible is at the bottom of the cladogram. Typically this is produced by arranging the terminal nodes ''downwards'' on the page in order of their evolutionary divergence. Compare the bottom row of the diagram to the top row.
 
 
 
===Large cladograms===
 
There are limitations on the size and complexity of the cladograms which can be drawn:
 
* A maximum of 17 children is allowed per node.
 
 
 
===Inclusion in books===
 
There are many known bugs in rendering tables in the software which produces [[Help:Books|Wikipedia books]]; see the [//meta.wikimedia.org/wiki/Book_tool/Feedback book tool feedback page]. {{as of|2011|July|}} these result in the lines in cladograms not displaying in books.</includeonly><noinclude>
 
{{doc|content=
 
This is the common part of the documentation for what used to be two templates {{tl|Clade}} and {{tl|Cladex}}, and needs to be replaced. For now, set the first parameter to "cladex" to select the full version.
 
}}
 
</noinclude>
 
 
 
== Graphical summary ==
 
 
 
{{Clade/doc/graphic summary}}
 

Latest revision as of 12:38, 3 November 2019

Redirect to: