Difference between revisions of "Template:Cladex/doc"

From blackwiki
Jump to navigation Jump to search
imported>Peter coxhead
imported>Dinoguy1000
(main template was redirected in 2018)
 
(35 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
+
#REDIRECT [[Template:Clade/doc]]
<!---PLEASE ADD METADATA TO THE <includeonly> SECTION AT THE BOTTOM OF THIS PAGE -->
 
 
 
This template is an eXtended version of {{tl|Clade}}, hence the name. Both templates are for drawing branching trees with the nodes and base labels being clickable links. Such diagrams are especially suited to represent evolutionary trees.
 
 
 
Most of the documentation is the same as the parent template, {{tl|Clade}}, and is included below for convenience. Unless the two extra features of {{tl|Cladex}} are needed, you are advised to use {{tl|Clade}}.
 
 
 
The two extra features of {{tl|Cladex}} are:
 
* Double lines leading to a node can be used as easily as dotted lines.
 
* Brackets or bars of a chosen colour can be placed to the right of a set of leaf nodes in the cladogram, thus allowing [[Paraphyly|paraphyletic]] groups to be identified. See [[#Bracketting nodes]]. Note that this feature only works with a cladograms of a limited set of shapes.
 
 
 
{{tl|Clade}} and {{tl|Cladex}} can be freely mixed, so if only one clade requires either of the extra features, only this one need be specified using {{tl|Cladex}}.
 
 
 
==Basic features==
 
 
 
=== Usage ===
 
 
 
<pre>
 
<nowiki>
 
{{cladex
 
|label1=Base
 
|1=Node
 
}}
 
</nowiki>
 
</pre>
 
 
 
produces
 
 
 
{{cladex
 
|label1=Base
 
|1=Node
 
}}
 
 
 
<pre>
 
<nowiki>
 
{{cladex
 
|1={{cladex
 
  |label1=[[Subtree1]]
 
  |1=Leaf1
 
  |label2=Subtree2
 
  |2=[[Leaf2]]
 
  }}
 
}}
 
</nowiki>
 
</pre>
 
 
 
produces
 
 
 
{{cladex
 
|1={{cladex
 
  |label1=[[Subtree1]]&nbsp;
 
  |1=Leaf1
 
  |label2=Subtree2&nbsp;
 
  |2=[[Leaf2]]
 
  }}
 
}}
 
 
 
<pre>
 
<nowiki>
 
{{cladex| style=font-size:75%;line-height:75%
 
|1={{cladex
 
  |label1=Subtree1
 
  |1=Leaf1
 
  |label2=Subtree2
 
  |2=Leaf2
 
  }}
 
}}
 
</nowiki>
 
</pre>
 
 
 
produces
 
 
 
{{cladex| style=font-size:75%;line-height:75%
 
|1={{cladex
 
  |label1=Subtree1
 
  |1=Leaf1
 
  |label2=Subtree2
 
  |2=Leaf2
 
  }}
 
}}
 
 
 
<pre>
 
<nowiki>
 
{{cladex
 
|1={{cladex
 
  |1={{cladex | thickness=3
 
      |1=Leaf1
 
      |2=Leaf2
 
      }}
 
  |2=Leaf3
 
  }}
 
}}
 
</nowiki>
 
</pre>
 
 
 
produces
 
 
 
{{cladex
 
|1={{cladex
 
  |1={{cladex | thickness=3
 
      |1=Leaf1
 
      |2=Leaf2
 
      }}
 
  |2=Leaf3
 
  }}
 
}}
 
 
 
To replace the solid line with a dashed line, use |stateN=dashed:
 
<pre>
 
<nowiki>
 
{{cladex
 
|1={{cladex
 
  |1={{cladex
 
      |1=Leaf1|state1=dashed
 
      |2=Leaf2
 
      }}
 
  |2=Leaf3
 
  }}
 
}}
 
</nowiki>
 
</pre>
 
 
 
produces
 
{{cladex
 
|1={{cladex
 
  |1={{cladex
 
      |1=Leaf1|state1=dashed
 
      |2=Leaf2
 
      }}
 
  |2=Leaf3
 
  }}
 
}}
 
 
 
'''{{tl|Cladex}} only.''' To replace a single line leading to the Nth child by a double line, use <tt>|stateN=double</tt>:
 
<pre>
 
<nowiki>
 
{{cladex
 
|1={{cladex
 
  |1={{cladex
 
      |1=Leaf1
 
      |2=Leaf2|state2=double
 
      }}
 
  |2=Leaf3
 
  }}
 
}}
 
</nowiki>
 
</pre>
 
 
 
produces
 
{{cladex
 
|1={{cladex
 
  |1={{cladex
 
      |1=Leaf1
 
      |2=Leaf2|state2=double
 
      }}
 
  |2=Leaf3
 
  }}
 
}}
 
 
 
=== 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>"{{cladex|"</nowiki>
 
# Replace ")" with <nowiki>"}}"</nowiki>
 
# Edit to replace commas with pipes and numbers
 
# Edit clade labels if needed
 
<pre>
 
<nowiki>
 
{{cladex
 
|1={{cladex
 
    |1=a
 
    |2=b
 
    }}
 
|2={{cladex
 
    |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('','{{cladex',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.
 
Use within [[Template:Cladogram]].
 
{{cladogram|title=Example
 
|caption=Sample of Template:Cladogram
 
|clades={{cladex| style=font-size:75%;line-height:75%
 
|label1=[[Neornithes]]&nbsp;&nbsp;
 
|1={{cladex
 
|label1=[[Paleognathae]]
 
|1=&nbsp;
 
|label2=&nbsp;[[Neognathae]]&nbsp;
 
|2={{cladex
 
  |1=Other birds
 
  |label1=&nbsp;
 
  |label2=[[Galloanserae]]&nbsp;
 
  |2={{cladex
 
      |1=[[Anseriformes]]
 
  |label2=&nbsp;&nbsp;&nbsp;&nbsp;
 
  |2={{cladex
 
      |1=[[Galliformes]]
 
      |2=[[Craciformes]]
 
      }}
 
      }}
 
  }}
 
      }}
 
  }}
 
}}<pre>
 
{{cladogram|title=Example
 
|caption=Sample of Template:Cladogram
 
|clades={{cladex| style=font-size:75%;line-height:75%
 
|label1=[[Neornithes]]&nbsp;&nbsp;
 
|1={{cladex
 
|label1=[[Paleognathae]]
 
|1=&nbsp;
 
|label2=&nbsp;[[Neognathae]]&nbsp;
 
|2={{cladex
 
  |1=Other birds
 
  |label1=&nbsp;
 
  |label2=[[Galloanserae]]&nbsp;
 
  |2={{cladex
 
      |1=[[Anseriformes]]
 
  |label2=&nbsp;&nbsp;&nbsp;&nbsp;
 
  |2={{cladex
 
      |1=[[Galliformes]]
 
      |2=[[Craciformes]]
 
      }}
 
      }}
 
  }}
 
      }}
 
  }}
 
}}</pre>
 
 
 
==Bracketting nodes==
 
'''{{tl|Cladex}} only.'''
 
 
 
To insert a coloured 'bracket' around a set of leaf nodes which follow one another in the generated cladogram:
 
* Add <tt>barbeginN=''colour''</tt> for the first node, where N is its order as a child and ''colour'' is the required colour.
 
* Add <tt>barN=''colour''</tt> for the remaining nodes other than the last (note that N must be the order of that node as a child of its parent).
 
* Add <tt>barendN=''colour''</tt> for the last node.
 
 
 
<pre>
 
<nowiki>
 
{{cladex
 
|1={{cladex
 
  |1=Leaf A
 
  |2=Leaf B|barbegin2=green
 
  |3=Leaf C|bar3=green
 
  |4={{cladex
 
      |1=Leaf D|barend1=green
 
      |2=Leaf E
 
      |3=Leaf F|barbegin3=purple 
 
      |4={{cladex
 
        |1=Leaf G|bar1=purple
 
        |2=Leaf H|barend2=purple
 
        }}
 
      }}
 
  }}
 
}}
 
</nowiki>
 
</pre>
 
 
 
produces
 
{{cladex
 
|1={{cladex
 
  |1=Leaf A
 
  |2=Leaf B|barbegin2=green
 
  |3=Leaf C|bar3=green
 
  |4={{cladex
 
      |1=Leaf D|barend1=green
 
      |2=Leaf E
 
      |3=Leaf F|barbegin3=purple 
 
      |4={{cladex
 
        |1=Leaf G|bar1=purple
 
        |2=Leaf H|barend2=purple
 
        }}
 
      }}
 
  }}
 
}}
 
 
 
The horizontal lines can be omitted by using <tt>|barN=''colour''</tt> throughout. Thus
 
 
 
<pre>
 
<nowiki>
 
{{cladex
 
|1=Leaf A
 
|2={{cladex
 
  |1=Leaf B|bar1=midnightblue
 
  |2=Leaf C|bar2=midnightblue
 
  }}
 
|3=Leaf D|bar3=midnightblue
 
}}</nowiki>
 
</pre>
 
 
 
produces
 
{{cladex
 
|1=Leaf A
 
|2={{cladex
 
  |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 example above, it may be tempting to write
 
 
 
<pre>
 
<nowiki>
 
{{cladex
 
|1=Leaf A
 
|bar2=midnightblue
 
|2={{cladex
 
  |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 work!
 
 
 
===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 <tt>rgb()</tt> notation.
 
 
 
===Limitations, work-arounds===
 
 
 
{{tl|Cladex}} like {{tl|Clade}} uses the browser's (user agent's) algorithms for drawing tables. As these differ from browser to browser, the cladograms produced will not look the same on all browsers.
 
 
 
In some cases, extra space has to be added to the name of one of the leaves. Consider the following example.
 
<pre>
 
<nowiki>
 
{{clade
 
|1={{clade
 
  |1=Leaf A
 
  |2={{cladex
 
      |1=Leaf B|barbegin1=purple
 
      |2={{cladex
 
        |1=Leaf C has a very long name and causes problems|bar1=purple
 
        |2={{cladex
 
            |1=Leaf E|barend1=purple
 
            |2=Leaf F
 
            }}
 
        }}
 
      }}
 
  }}
 
}}</nowiki>
 
</pre>
 
 
 
==Size limitations==
 
 
 
Both {{tl|Clade}} and {{tl|Cladex}} have some size limitations.
 
* Both currently allow only a maximum of 17 children per node. It may seem that this could easily be increased by editing the templates, but see the next point.
 
* Both will only expand a cladogram up to a certain level of complexity. The cladogram at [[APG_III_system#Phylogeny]] has had to be broken into two parts, because {{tl|Clade}} will not handle the entire cladogram. Because {{tl|Cladex}} has more complex internal code, it runs out of the allowed resources for template expansion sooner, and will only handle templates which are slightly smaller. ''Any change to either of these templates could result in larger cladograms failing to display correctly.''
 
<includeonly>
 
<!-- Categories and interwikis go here: -->
 
 
 
[[Category:Genealogy formatting templates|{{PAGENAME}}]]
 
[[Category:Wikipedia formatting and function templates|{{PAGENAME}}]]
 
 
 
</includeonly>
 

Latest revision as of 13:17, 29 January 2020

Redirect to: