Jump to content

Template talk:Clade

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Documentation is at Template:Clade/doc. Please check Template:Clade/doc#Limitations before raising a problem here.


2007

[edit]

I'm afraid this template is not ready for the big time, as it has a number of problems:

1.If a label is long, it wraps, thereby potentially breaking the connection of its line to its subclade. e.g.

B. ser. Abietinae

2. If you use non-breaking whitespace to prevent wrapping, the subclades get squashed up. e.g.

3. Label widths are determined by the widths of labels of sister labels, but not of any other labels at the same rank. This looks silly when one unlabelled clade has a longer stem than all the others. This can be seen in the example above.

I have fiddled for hours in my sandbox, and I'm afraid all these problems have defeated me. If someone could possible figure out a solution, it would be much appreciated. Hesperian 05:37, 21 October 2007 (UTC)[reply]

The collapse problem could probably be avoided by including invisible spacer elements, like the <div>s used in Template:Familytree. This may be as easy as including some &nbsp;s somewhere, but I haven't really looked at the code of this template closely enough to tell yet. I'm too tired to do that now, but I'll see if I can find some time for it later. One general suggestion I'd make, based on my experience with the familytree template, is to use HTML table syntax instead of wikitables: you're likely to see a significant improvement in the parsing speed of complex trees. —Ilmari Karonen (talk) 22:44, 27 October 2007 (UTC)[reply]

This template does not show up correctly in Safari and Konqueror. The latter passes the ACID2, so there must be some problems with the template itself. This template could be extremely useful (I've already used it in many articles), please fix these problems! Thank you very much! (see this discussion). Aelwyn 08:57, 3 November 2007 (UTC)[reply]

See Template:Clade/doc#Limitations.
When two sister clades are represented differently, one as a label for a subclade and the other as a leaf node, the layout may seem odd, as noted above. This is now discussed at Template:Clade/doc#Controlling_the_layout_of_sisters. Peter coxhead (talk) 10:27, 27 July 2011 (UTC)[reply]
Looking at my examples above, the problem has been fixed. It looked completely broken when I posted the comment back in '07. Hesperian 10:39, 27 July 2011 (UTC)[reply]
In my browser (Firefox), (1) isn't fixed (the lines don't join up), and (3) is still an issue, for which there are work-arounds. Peter coxhead (talk) 11:00, 27 July 2011 (UTC)[reply]
Works for me on Firefox 5 and IE 8, still looks awful in Chrome 12. Hesperian 11:48, 27 July 2011 (UTC)[reply]
Can I clarify this point with you please? (I'm still thinking about the clade template from time to time; I know how to fix the browser difference with extra user input, but not how to automate it. As far as I know, the manually constructed cladogram at User:Peter_coxhead/Test/Clade#Manual_fix_for_browser_difference looks the same in all browsers/platforms.)
I use a Mac. When I look at the two cladograms below, the first is ok in all browsers. The second is not.
B. subser. Sphaerocarpae

some taxa

some taxa

B. subser.
Sphaerocarpae

some taxa

some taxa

In Firefox, the second cladogram looks like the left hand image below. In Safari and Opera, it looks like the right hand image below.
Neither are correct. The Firefox version is better, but like the Safari/Opera version, the first "some taxa" lines up with the label, not the line.
So on a Windows platform, does the second cladogram look ok in different browsers or not? (I would expect IE9 to look like the Firefox version; I'm not sure about IE8.) Peter coxhead (talk) 20:47, 27 July 2011 (UTC)[reply]
The right image is one of the problems I was complaining about in 2007. I now see the left image in Firefox 5 and IE 8 (on Windows). On Chrome I get something completely different as discussed elsewhere on this page. Hesperian 12:16, 28 July 2011 (UTC)[reply]

Editor

[edit]

Just in case there are potential users who are put off by the complexity, there is a simple utility over here that may help Windows users create Cladograms by visually editing the trees. http://code.google.com/p/claded/downloads/list

I wrote it, but do not think I might get to extend it further or support feature requests or bug reports, but the source code is out there for improvement. Shyamal (talk) 12:29, 18 April 2008 (UTC)[reply]

other lines

[edit]

Any possibility of dbl/triple lines for polyphyletic groups, or other common conventions? kwami (talk) 09:51, 25 November 2008 (UTC)[reply]

See #Double lines. Peter coxhead (talk) 16:24, 1 February 2011 (UTC)[reply]
It's now also easier to produce double lines by using {{Cladex}}. Peter coxhead (talk) 08:30, 27 July 2011 (UTC)[reply]

Fixed width?

[edit]

Is it possible to set a fixed width for the template? I know if you don't use the Template:Cladogram for naming and captions, you can enclose this template in a Template:userboxtop, like they have on Primate. But if you do that around a clade enclosed in a cladogram, it gets messed up. –Visionholder (talk) 20:29, 3 September 2009 (UTC)[reply]

Lemur phylogeny
Strepsirrhini 
 Lorisiformes 

Galagidae (Galagos)

Lorisidae (Lorises)

 Lemuriformes 

Daubentonia (Aye-aye)

Indriidae (Sifakas, Indris, and Wolly lemurs)

Lepilemuridae (Sportive lemurs)

Cheirogaleidae (Mouse lemurs and allies)

Lemuridae (Brown lemurs and allies)

Source: Horvath, et al. (2008)[1]


References

  1. ^ a b Cite error: The named reference 2008Horvath was invoked but never defined (see the help page).

I don't understand your rationale, but the answer to your question is yes. Pass a width: value to the style parameter. e.g. in the above examples, replace

{{Clade|style=font-size:75%

with

{{Clade|style=font-size:75%; width:100em

Hesperian 23:16, 3 September 2009 (UTC)[reply]

Thank you for the fix! I had tried passing a width parameter, but I must have had the syntax wrong. I'm not sure why Primate enclosed their cladogram in a Template:userboxtop, if that's what you meant by my "rationale," but I will probably go in and fix it for them soon. By the way... is the alignment syntax pretty straightforward? –Visionholder (talk) 17:37, 4 September 2009 (UTC)[reply]
If you mean tweaking the alignment of clades within the cladogram, I don't think it can be done. If you mean getting the cladogram to center or float left instead of right, there's no provision for it at present.
I've converted Primate to use {{cladogram}}, but this doesn't really change anything, since {{cladogram}} itself uses {{userboxtop}} and {{userboxbottom}}. Very odd.
Hesperian 05:02, 5 September 2009 (UTC)[reply]

Depth problem with no warning

[edit]

The cladogram at APG III system#Phylogeny seems to exceed the allowed depth without any warning. The very last part of the cladogram does not display (there should be another clade below "Apiales"). It's not present when I use "view source" in my browser to see the table generated by the template, although the template code seems to be correct. If I replace "Apiales" by {{clade ... }}, then I get a depth exceeded warning. Anyone able to fix this? Peter coxhead (talk) 08:20, 20 April 2010 (UTC)[reply]

Dashed lines?

[edit]

Is there a way to add dashed lines for uncertain relationships? – VisionHolder « talk » 23:38, 20 May 2010 (UTC)[reply]

Now there is: |stateN=dashed. Ucucha 20:38, 31 May 2010 (UTC)[reply]

Browser differences - Chrome vs. Firefox

[edit]
How the cladogram for Drosera regia looks in Firefox 3.6.8; "normal"
Same cladogram in Google Chrome 6.0.472.59; "weird"

I just switched from using Firefox to Google Chrome and noticed some of my cladograms using this template and {{cladogram}} look odd. Is this a fixable problem? Rkitko (talk) 13:28, 19 September 2010 (UTC)[reply]

In Safari, they look as in Google Chrome. I guess it is related to how the browser interprets the empty table cells that {{clade}} uses. I have no idea whether we can change the template so that Chrome and Safari interpret it the same way as Firefox does. Ucucha 14:57, 19 September 2010 (UTC)[reply]
I hadn't opened IE in the longest time, but I braved it to satisfy my curiosity. The cladogram appears the same in IE as it does in Firefox. Perhaps some template guru could help? Rkitko (talk) 15:16, 19 September 2010 (UTC)[reply]
Firefox 3.6.10, IE 7.0.5730.13: as per left-hand screenshot. Chrome 6.0.472.59, Opera 10.62: as per right shot. --Redrose64 (talk) 16:02, 20 September 2010 (UTC)[reply]
If the problem is with empty table cells, one could put say a &thinsp; in the empty cells. I don't know if this would fix the problem, or make it worse. Plastikspork ―Œ(talk) 20:25, 3 October 2010 (UTC)[reply]
I think there are already nbsp's in these cells. Ucucha 20:33, 3 October 2010 (UTC)[reply]
I see. I checked the output source and found some <br>, but didn't see any nbsp. It could be my browser or mediawiki stripping them out. Plastikspork ―Œ(talk) 21:49, 3 October 2010 (UTC)[reply]
Non-breaking spaces don't help. the problem is (AFAICS) that Safari and Chrome are actually behaving correctly per W3 standards (in a somewhat obsessive way, perhaps), and this is mucking up the hack that lets the tables look nice in firefox. A two row table should normally determine row-height by the height of the contents (with the last row taking up the slack); it shouldn't assume that the rows get equal heights. If we knew in advance the height of the table, we could set the height of the table rows explicitly, (which solves the problem, more or less, in Safari) but I'm not yet seeing a way to resolve it in the abstract case. I've been debating whether it would be easier to convert the whole clade template to DIVs, but I think that would cause more problems than it solves. --Ludwigs2 21:54, 3 October 2010 (UTC)[reply]
P.s... There might be a solution by converting the #1 column (with the connector line) into a table as well. let me play with it a bit. --Ludwigs2 22:33, 3 October 2010 (UTC)[reply]
A lot of what you said above flies way over my head, so I appreciate any help you can offer :-) Rkitko (talk) 02:19, 4 October 2010 (UTC)[reply]

As there has been no talk here I am thinking this may have been fixed with Chrome? but I am a Safari user and I still see the "weird" lines... (Just finished adjusting E.coli table and it looks hideous) --Squidonius (talk) 01:44, 27 July 2011 (UTC)[reply]

No, it's still looking as bad in Chrome. Also, some of your most recent edits also messed up the cladogram in Firefox—the very long |label= texts are somehow pushing the branch down below its child nodes. Ucucha 02:15, 27 July 2011 (UTC)[reply]
There's a discussion of browser differences below at #New version of clade template – look for the bold text "short answer". It's important to keep the labelN= text as short as possible, and always use &nbsp; instead of real spaces in such labels. I have expanded Template:Clade/doc#Limitations to cover these issues. Peter coxhead (talk) 09:19, 27 July 2011 (UTC)[reply]
thanks. I did not notice that the internal node names were too long for IE to handle correctly, so I've fixed that. --Squidonius (talk) 11:46, 28 July 2011 (UTC)[reply]
New versions of Chrome (I'm using Version 54.0.2840.99 m) seem to be rendering the tables the same way as Firefox. The cladograms for Drosera regia and Escherichia coli mentioned above both appear "properly" and so do other clade-based trees I've checked. Microsoft Edge also displays the trees in the desired way. I haven't checked Safari or Opera. Jts1882 (talk) 10:31, 5 December 2016 (UTC)[reply]

Nowrap

[edit]
Is there any context in which we would need the |labelN= to wrap? If not, we could put {{nowrap}} around them in this template. Ucucha 12:06, 28 July 2011 (UTC)[reply]
I think that the label must NEVER wrap; the results if it does are always incorrect on all browsers according to the tests I've made. The diagram below shows an example of what happens when the label is forced to wrap.
In the Firefox/IE group of browsers (left-hand side), the result is not too bad, but the first "some taxa" lines up with the label, not the line. In Safari/Opera group (right-hand side), this problem is also present, but the lines are quite wrong.
I'm wary of making any changes to {{clade}} because of the issue noted at Template:Clade#Large_cladograms. A further template expansion (i.e. the {{nowrap}} template) will surely consume more resources and so break some existing large cladograms.
(Btw, I have written elsewhere that I know how to fix browser differences manually but not automatically. It turns out I was wrong; I can do it in all current browsers I've tested except IE9. Sigh...) Peter coxhead (talk) 17:18, 28 July 2011 (UTC)[reply]
Do you know what exactly the problem is with large cladograms (i.e., what template limit is exceeded)? If the problem is the sheer size of the template text, there are quite a few spaces that can be removed from the code.
We don't necessarily need to use the nowrap template; we can also use the raw tag (<span style="white-space:nowrap;">) instead. Ucucha 23:58, 28 July 2011 (UTC)[reply]
I now see the problem is the expansion depth limit (WP:UNNEST), i.e. the maximum number of templates you can load inside another template. If we just add the span, that shouldn't affect the expansion depth limit. Ucucha 00:04, 29 July 2011 (UTC)[reply]
I agree, but I'm still wary! I'll experiment with a copy of the template in my user space + the cladogram at APG_III_system#Phylogeny whose first half is at the very limit of the current template's capacity. Peter coxhead (talk) 09:32, 29 July 2011 (UTC)[reply]
Tests showed that we were right, and this change does not alter the resource limit, so I have changed the template (I'll do the related {{cladex}} later and fix the documentation of both). I'll post a new 'warning' note which is more likely to be read, perhaps. Peter coxhead (talk) 09:57, 29 July 2011 (UTC)[reply]

Double lines

[edit]

There's a convention to show double lines for a paraphyletic group (e.g. a stem group). This is possible by the following trick. Use "stateN=double;border-bottom-width:3px;border-bottom-color:" for any line that you want to be double, where N = 1, 2, 3, etc. (Just "stateN=double" doesn't work because the line needs to be at least 3px thick to show as double.) There's an example at the source of Template:Clade euphyllophyte. Peter coxhead (talk) 16:29, 1 February 2011 (UTC)[reply]

It's now easier to do this via {{Cladex}}; see its documentation. Peter coxhead (talk) 09:25, 27 July 2011 (UTC)[reply]

How to highlight a path?

[edit]

Is there a way to highlight a path from the origin to a leaf? I've used CSS background-color to highlight the leaf, but it's long way from the origin, and highlighting the path from the origin to the leaf would make it easier for readers. --Philcha (talk) 21:12, 13 April 2011 (UTC)[reply]

How to reduce space between lines?

[edit]

Is there a way to space between lines (clades and leafs), to make it easier to see cladograms that take a lot of vertical space but without reducing the font size? --Philcha (talk) 21:12, 13 April 2011 (UTC)[reply]

The spacing can be reduced a bit by putting "|style=line-height:100%" after the first "clade". Compare the first two versions below: the first is without any styling information, the second sets the line height to 100%. I now make a habit of always setting this value.

Leaf 1

Leaf 2

Leaf 3

Leaf 1

Leaf 2

Leaf 3

Leaf 1

Leaf 2

Leaf 3

Unfortunately, setting line-height to less than 100% doesn't make any difference in my testing; to get things closer you need to reduce the font size. The third one above has "line-height:100%;font-size:80%". Peter coxhead (talk) 16:16, 14 April 2011 (UTC)[reply]

in line alignment and width

[edit]

On Gammaproteobacteria, I cannot change the width, but I want it set to align=none (i.e. no word-wrapping). Is that due my incompetence or are they mutually exclusive? --Squidonius (talk) 21:21, 3 May 2011 (UTC)[reply]

Try using the no-break space (&nbsp;) in place of spaces when you have lists of taxa. That will force it to stop word wrapping. Also remember to italicize genera. Cheers, Rkitko (talk) 21:43, 3 May 2011 (UTC)[reply]

Java clade processor applet

[edit]

I'm currently working on the clade processor's parser. Does this BNF grammar look correct?

<begin> ::= "{{User:Peter coxhead/Template/Clade" {<style>}

<end>::= "}}"

<cladogram> ::= <begin> <clade> {<clade>} <end>

<clade> ::= <node> {<clade>}

<node> ::= (<label> <clade> | <taxon>)

<label> ::= "|label" <number> "=" <text>

<taxon> ::= "|" <number> "=" <text> {"|r" <number> "=<decimal>px" | <bar>}

<bar> ::= {"s"|"e"}"bar"("1"|"2"|"3"|"4"|"5")"="<color>

<number> ::= <decimal> {<number>}

<text> ::= (<letter>|<number>|"&nbsp;"|whitespace|":"|"%") {<text>}

<style> ::= "|style="<text>

<letter> ::= ("A"|"a"|"B"|"b"|"C"|"c"|"D"|"d"|"E"|"e"|"F"|"f"|"G"|
              "g"|"H"|"h"|"I"|"i"|"J"|"j"|"K"|"k"|"L"|"l"|"M"|"m"|
              "N"|"n"|"O"|"o"|"P"|"p"|"Q"|"q"|"R"|"r"|"S"|"s"|"T"|
              "t"|"U"|"u"|"V"|"v"|"W"|"w"|"X"|"x"|"Y"|"y"|"Z"|"z")

<decimal> ::= ("0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9")

<hex> ::= (<decimal>|"A"|"a"|"B"|"b"|"C"|"c"|"D"|"d"|"E"|"e"|"F"|"f")

<color> ::= ("#"<hex><hex><hex>{<hex><hex><hex>}|<text>|
            "rgb("(("25"("0"|"1"|"2"|"3"|"4"|"5")|
                    "2"("0"|"1"|"2"|"3"|"4")<decimal>|
                    "1"<decimal><decimal>|
                    <decimal>{<decimal>})")")

Bob the WikipediaN (talkcontribs) 20:27, 31 May 2011 (UTC)[reply]

Updated. Bob the WikipediaN (talkcontribs) 21:15, 31 May 2011 (UTC)[reply]
Some quick notes. The "cell=0|1" bit will be removed if this template is indeed useful and can be released; I only put it there so I could see exactly how the output was built. The original {{clade}} provides for up to 17 children from a node, so obviously I need to edit my version up to that number. Any valid HTML colour specification will do: a colour name, or rgb() or #FFF or #FFFFFF type formats. There's at least one more parameter in {{clade}}, namely thickness. I guess there should be one for the thickness of the 'bracket'.
Not sure if "sbar", "bar" and "ebar" are good parameter names; I favour short ones, but perhaps "startbar", "bar" and "endbar" would be better. Any views?
I realize that what I wrote early about vertical text wasn't perhaps clear.
  • I was pretty sure I could generate text vertically, because I've done it before, provided that the Wikimedia software didn't remove the CSS, which it turns out that it doesn't.
  • BUT I still can't see how to get the vertical text in the right place. However, Petter seems to think that just having coloured 'brackets' is useful; I wasn't sure that it was.
I still find {{clade}} confusing to use, particularly the need to specify different numbered parameters for each child. So I look forward to a more user-friendly system. Peter coxhead (talk) 22:04, 31 May 2011 (UTC)[reply]
Perhaps |bar=, |bartop=, and |barbottom= would be more intuitive than what you've got already. I must admit, I wondered what on earth "s" and "e" stood for (but hadn't scrutinized the implementation of it yet, or I might have arrived at the proper conclusion). If I get a minute tonight I'll have a look and see if I can't figure out how to help your vertical text placement issue. I've updated the BNF in accordance with your quick notes. Bob the WikipediaN (talkcontribs) 01:13, 1 June 2011 (UTC)[reply]
I find a coloured bracket useful (or just a black one if there's only one). I would prefer text, but if it is impossible the colour coding is the second best solution. The really interesting question is if this is possible to implement in a proper cladogram editor. Petter Bøckman (talk) 08:46, 1 June 2011 (UTC)[reply]
I think what I'll end up doing is a tree-directory style layout with buttons to add or remove nodes. If this proves successful, someone with graphics capabilities might chime in and help us out with that. Bob the WikipediaN (talkcontribs) 16:51, 1 June 2011 (UTC)[reply]
Petter, thanks for your comment. At some point, I will update {{Clade}} to include drawing coloured brackets.
Bob: yes, I agree that |bar=, |bartop=, and |barbottom= would be more intuitive! I'll clean up my version of the clade template (including duplicating the 'bar facility' to all 17 possible children), but I won't move it to the real {{Clade}} until you have looked at whether you can draw vertical text. (I worry that it will only work on some browsers.)
I'd also like to make drawing double lines easier than as at Template_talk:Clade#Double_lines; it's just a matter of the template logic making the line thickness >= 3px when the 'state' is set to double.
Btw, I'm travelling later this week, so not sure of internet access. Peter coxhead (talk) 06:59, 2 June 2011 (UTC)[reply]

New version of clade template

[edit]

(I've started a new section for clarity, but note that the immediately above section has relevant posts too.)

I've been working on a new version of the clade template, with one major and one minor improvement in mind:

  • Major: the ability to put a bar or bracket at the right hand side to mark paraphyletic groups (e.g. stem groups).
  • Minor: proper support for a double line, rather than the 'fix' as at #Double_lines.

Both of these work now. See User:Peter coxhead/Test/Clade – note that this is subject to change as the transcluded templates change.

I had hoped to replace {{Clade}} by my version, but there's a problem. Presumably because of the extra processing required to deal with the bar/bracket, the maximum expansion depth is reached sooner with my version than the old one, so that the cladogram at APG_III_system#Phylogeny, which reaches the maximum expansion depth of {{Clade}}, fails earlier with my version. Unless I can fix this (at the moment I'm calling an auxiliary template rather than expanding inline for all 17 possible children as {{Clade}} does), I'll have to give my version a new name.

  • Any suggestions for a new name for my version?

For the present, I'm continuing to run tests and try slightly different coding. Peter coxhead (talk) 05:58, 7 June 2011 (UTC)[reply]

Inline expansion of the auxiliary template, which I've now done, allows a greater depth of cladogram than before, but not as deep as {{clade}}. This implies:
  • Since I can't tell whether there are any other articles in which the current version of {{clade}} reaches a depth greater than my new version can, I can't fix them and hence can't replace the current version by mine, so a new name is needed.
  • Since we can't tell whether there are any other articles in which the current version of {{clade}} reaches its maximum depth or close to it, it's dangerous to alter {{clade}} in any way, since this may reduce its maximum depth and cause existing cladograms to fail. This is annoying because I'd hoped to fix double-line production in the existing version.
Any one have any other ideas/comments? Peter coxhead (talk) 10:10, 7 June 2011 (UTC)[reply]
Wow, you've been busy. It's looks great. I like the added functionality. It's a minor point, but I notice the same browser issue as above with your template: #Browser differences - Chrome vs. Firefox. Any ideas on that? Rkitko (talk) 12:10, 7 June 2011 (UTC)[reply]
There's a short and a long answer to that. The short answer is as given above, namely that Safari, Opera and Chrome implement tables one way; IE and Firefox another. Since the template works by using the borders of table cells to 'draw' lines, there's no real fix. I suspect that if there were a way of making the Safari/Opera/Chrome group display in the way that the Firefox/IE group currently do, there would just be a new difference between the two groups of browsers, although I can't prove this.
The long answer is that this is actually a very clever way of 'drawing' a cladogram (introduced by User:Josh_Grosse). If you write an algorithm to draw a cladogram, it has to make two passes over the data structure which represents the tree: one to work out where to position things (because e.g. you need to know the total depth of the tree) and one to draw it. This is difficult to do in the template expression language. Instead, the 'Grosse method' converts the tree to a table structure in a single pass but, crucially, leaves the task of actually positioning the table cells to the browser's algorithm for laying out tables. It was suggested above that divs could be used, but there is no equivalent built-in algorithm for laying out nested divs; the template would have to calculate the sizes of the divs, which would (as far as I can see) require two passes. So the 'Grosse method' has a crucial strength which turns out to be a crucial weakness: it uses the browser's algorithm for laying out complex tables but there are at least two different algorithms in use in browsers. So we appear to be stuck – unless someone can come up with a radically different way of doing it which is also browser independent. Peter coxhead (talk) 15:56, 7 June 2011 (UTC)[reply]
Rather than making it platform-independent, we can make it platform-conforming. We could add in a bit that renders it differently depending on the browser being used-- this is actually a fairly common practice in HTML. But the question is-- this we do it? Bob the WikipediaN (talkcontribs) 21:02, 7 June 2011 (UTC)[reply]
As far as I can see from further experiments, the only way to make both groups of browsers produce the same output is to explicitly set the height property on two specific cells – you only need to do this for the Safari/Opera/Chrome group, but it turns out that it does no harm for the other group, so we wouldn't need browser detection. However, the height value to be set is dependent on the number of leaf nodes spanned by those two cells. Since I don't see how to pass through the current clade template twice, the only solution is for the user to set the size manually. In other words, whenever there is currently something like:
|label2=taxon
|2={{clade ...
you would have to have something like:
|label2=taxon
|size2=7
|2={{clade ...
where 7 is the total number of leaf nodes present in the clade template INCLUDING any clade templates it encloses. I'm doubtful that it's worth implementing this, although I know in principal how to do it.
Bob, you've done more template programming than me: can you think of a way of representing the cladogram as a data structure which can be passed through twice, once to count leaf nodes, and then to generate the table representation? Peter coxhead (talk) 04:58, 8 June 2011 (UTC)[reply]

New name: One idea is to call the new version "cladex" for "clade extended": it needs to be a short word because you have to type it repeatedly when setting up a complex cladogram, so I wouldn't use something like "Template:Clade/extended" or "Template:Clade extended". Another is to call it "cgram" for "cladogram", which is actually more logical than "clade". Any views? Peter coxhead (talk) 05:06, 8 June 2011 (UTC)[reply]

I'd go with "cladogram". Petter Bøckman (talk) 06:55, 8 June 2011 (UTC)[reply]
Peter, if you need to loop, you could do something like this:
{{dosomething}}{{#if:{{#expr:2>{{{1}}}}}|1|{{dosomething}}|{{#if:{{#expr:3>{{{1}}}}}|1|{{dosomething}}|{{#if:{{#expr:4>{{{1}}}}}|1|{{dosomething}}}}}}}} et cetera
That should work, provided you have enough iterations to cover the maximum size. Bob the WikipediaN (talkcontribs) 14:28, 8 June 2011 (UTC)[reply]

Cladex template now available

[edit]

See {{Cladex}} for a version of this template which allows brackets or bars to be drawn on the right-hand side of the cladogram.

Note that {{Cladex}} runs out of the allowed resources for template expansion sooner than {{Clade}}, so use with caution on a very large cladogram!

I'd like to be able to add labels to the brackets/bars, but at present this defeats me, so I thought it better to release the existing version as it is. Peter coxhead (talk) 09:49, 21 June 2011 (UTC)[reply]

I'm going to give this a go! Thanks for your hard work Peter! Now all we lack is a wysiwyg-editor, and we will have an exceptionally great resource! Petter Bøckman (talk) 10:51, 21 June 2011 (UTC)[reply]

Labelling the brackets/bars is now possible: see {{Barlabel}}. There is not 100% uniformity of placement of the labels across browsers, but it seems to work quite acceptably in those tested so far (final tests of IE6 are pending). Peter coxhead (talk) 10:20, 1 July 2011 (UTC)[reply]

Tests of IE6 were carried out and it seemed to be ok. Peter coxhead (talk) 09:26, 27 July 2011 (UTC)[reply]

Cladograms in books

[edit]

This template doesn't appear to display correctly in Wikipedia Books. I have just examined the contents of Book:Crustacea, and among its many problems, I noticed that although the {{cladogram}} in the article krill does appear, the branches are invisible (it's on p. 125 of what is unfortunately quite a large book: 65 MB). Can anyone suggest a reason why this should happen? Can anyone fix it? --Stemonitis (talk) 14:04, 22 July 2011 (UTC)[reply]

Interesting. It seems to be a generic problem with the clade template, e.g. I converted just User:Peter_coxhead/Test to a book and the branches are invisible. If you convert the page to a PDF, it's fine – which is odd, because a "book" should be nothing more than a collection of PDF pages. I'll do some more tests, but I think the answer is that there must be something wrong with the software which renders articles into books, since the clade template works with all known browsers/operating systems. Peter coxhead (talk) 18:36, 22 July 2011 (UTC)[reply]
Further tests show that tables are not, in general, rendered in a book in the same way that they are by a browser. Since the branches 'drawn' by {{clade}} are actually the borders on the relevant sides of table cells, it's a "table issue" rather than a "clade template issue". Searching around, including [1], it seems that there are many known bugs in rendering tables in books. I'll flag up this particular issue there. Peter coxhead (talk) 18:55, 22 July 2011 (UTC)[reply]

Ah, OK. Thanks, Peter. --Stemonitis (talk) 06:06, 23 July 2011 (UTC)[reply]

I have expanded Template:Clade/doc#Limitations to cover this issue. There seems no activity at present at book tool feedback unfortunately. Peter coxhead (talk) 09:27, 27 July 2011 (UTC)[reply]

Change to template

[edit]

Following the discussion at #Nowrap above, I have edited the template so that the text displayed by is enclosed in a span tag which prevents line wrapping (unless someone explicitly inserts a line break, e.g. via <br>). This avoids the need to keep using &nbsp; in the text of labels instead of real spaces.

Tests suggest that this does not break existing cladograms, but I am wary of changes to this template, so if you notice any new oddities, please report them here (and revert the change if serious). Peter coxhead (talk) 10:03, 29 July 2011 (UTC)[reply]

Coloring cladogram lines?

[edit]

Is there any way to color the cladogram lines themselves? I understand that it's possible to color the background of text, and it's possible to add colored bars with CladeX, but how about the lines of the cladogram themselves? Seems like it would be very-very useful. VilmarVeldre (talk) 10:52, 24 May 2012 (UTC)[reply]

It would be possible to alter the template to allow the colour of lines to be selected. However, it's important to understand how the template actually works, which is by producing a complex nested set of tables in which some cells have borders – the cladogram lines – and others don't. So selecting which lines get coloured isn't not easy. The horizontal lines are part of one cell, but the vertical lines are actually drawn in two parts, which relate differently to the horizontal lines depending on the browser. Consider these two cladograms:

Leaf3

Leaf1

Leaf2

Leaf3

Leaf1

Leaf2

(If possible look at them in a browser from each group, e.g. Internet Explorer or Firefox and Chrome or Safari.) It would be easy to replace the thickened lines in the first by coloured lines, and the dashed line in the second by a coloured line. What would be impossible to make work in both groups of browsers is to colour a line from the root to a particular leaf, because of the way the lines are drawn.
Which lines exactly would you want to show in colour? Peter coxhead (talk) 14:58, 24 May 2012 (UTC)[reply]

Clad line lengths

[edit]

Hello

Is it possible to somehow manipulate the lengths of individual cladogram lines/ taxa/ leafs ? (eg to infer information about time-spans between branching events)

Slovenski Volk (talk) 02:44, 6 June 2015 (UTC)[reply]

Whatever the answer, one can make cladograms, etc on MS Word "freehand" and very easily manipulate & adapt using 'insert' 'shapes'. This is probably the best way. Slovenski Volk (talk) 01:09, 7 June 2015 (UTC)[reply]
The template works by creating a table in HTML and then creating borders along the sides of some of the cells. The layout is largely created by the browser (user agent). So the short answer is that although some control of the size of cells could be achieved (by some modifications to the template), it wouldn't really be a sensible approach to what you want. A drawing, preferably in SVG, would be the best approach.
The real value of the clade and cladex templates is that they make it easy to add and delete items without creating a new drawing each time. Peter coxhead (talk) 20:40, 12 June 2015 (UTC)[reply]

Illustrations

[edit]

The Tyrannosaurus article has featured an illustred cladogram since April 28, 2015. Is the use of illustrations recommended? A quick survey of the FA-class palaeontology articles shows that this practice is not very widespread. --Serpinium (talk) 10:02, 21 August 2015 (UTC)[reply]

I have to say it could look quite nice if the right images are used. Shyamal (talk) 10:11, 21 August 2015 (UTC)[reply]
I wouldn't say it's either recommended or discouraged, but I agree that it can look quite good. What you have to be aware of, though, is:
  • The appearance of cladograms constructed using this template varies between browsers, as per Template:Clade#Browser differences and in other ways, so a cladogram with images may not display well on all devices. My experience suggests that such cladograms work poorly in the mobile version of Wikipedia on devices with small screens (and in some countries these now make up the bulk of internet viewing).
  • The images need to be pretty small, as at Tyrannosaurus § Classification, otherwise it's hard to see the "shape" of the cladogram, so it only really works for easily seen gross differences.
Peter coxhead (talk) 11:16, 21 August 2015 (UTC)[reply]
Thank you for the help. I noticed that the Tyrannosaurus illustrations were photos of skeletons, not artists' reconstructions; should this be extended to all extinct species for which no photographs are available? --(talk) 12:04, 21 August 2015 (UTC)[reply]
EDIT: Conversely, Dimetrodon uses artists' reconstructions. --Serpinium

a puzzling issue on clade

[edit]

I've tried to create a linguistic tree of Tai-Kadai laguage family using clade, however there have been some problems. Firstly, "the root line", as I would call it, Proto-Daic=Kra-Dai does not appear in the middle of the tree but instead at its bottom [2]. Secondly, when using Google Chrome and Internet Explorer, the graph turns out to be like this: [3]. Is there something wrong with its code ? when using Firefox, the only thing gone wrong is Proto-Daic=Kra-Dai appears unexpectedly at the bottom. Could some expert on clade coding help me out with this problem ? I'm just a layman on this thing. Thanks very much. Bookworm8899 (talk) 15:13, 6 September 2015 (UTC)[reply]

Here is what it turns out to be. You'll see two different graphs when use Firefox or Google Chrome/IE.

 Proto‑Daic 
 =Kra‑Dai 
Hlaic

Hlai

Jia Mao

 Kra 
 (Kadai) 

Laha

 Gelao 
 Lachi 

 Buyang 
 Pubiao 
 En=Yenrong 
 Paha 

Kam‑Tai

 Lakkia 
 Biao 

Kam‑Sui

 Kam 
 Sui 
 Maonan 
 Mulam 
 Then 
 Mak 

Be–Tai
Be

Be

Tai
North

 N.Zhuang 
 Saek 
 Bouyei 
 Yay 
 Mene 

CT

 Nung 
 S.Zhuang 
 Tay 

South

 Thai 
 Lao 
 Shan 
 Tai Ahom 
 Tai Khamti 

See Template:Clade#Browser differences for why the template looks different in different browsers. See the note at the bottom of this section on how to lay out a cladogram to look best in both groups of browsers. Otherwise with my version of Firefox the cladogram looks exactly as I would expect.
"Stray" text at the bottom usually means mismatched curly brackets. Peter coxhead (talk) 19:21, 6 September 2015 (UTC)[reply]
Thanks for your advice. Now I understand why there are 2 different versions when use Firefox and Google Chrome/IE. On the mismatched curly brackets, I've checked the code again and again and find nothing wrong with it. Don't know what is the problem here. Could you check the code out to me and if find any mistake please fix that up ? Thanks Bookworm8899 (talk) 01:29, 7 September 2015 (UTC)[reply]
@Bookworm8899: if you mean the cladogram above, I don't see any stray text; it all seems ok to me. Peter coxhead (talk) 19:59, 7 September 2015 (UTC)[reply]
Ok. Thanks.Bookworm8899 (talk) 05:30, 9 September 2015 (UTC)[reply]
For what it's worth, for all involved, here's what I see on Firefox and Chrome, on Debian Linux:
--RProgrammer (talk) 19:15, 4 June 2016 (UTC)[reply]

Explanation of Extinction and other conventions (for non-biologists/linguists)

[edit]

I (re?)discovered today that the † is used to convey extinction in biology (and possibly linguistics?), notably in clade trees. Since it requires a bit of digging around for someone to learn that, and to be clear about what the †'s are intended to mean, I considered replacing the daggers with links like:

But it turns out that this can also be done with Wikipedia template code to replace all daggers in all clade trees across all pages instantly! I'll leave it up to the Wikipedia community to decide if they want this feature (since clade trees might be used beyond biology and linguistics, idk), but here is the code (below here, on the rendered version of this page, not its source).

Substitute the principal {{{1}}}, {{{2}}}, etc.s with:
{{replace|{{{1 or 2 or etc.}}}|†|[[Extinct|&#8224;]]}}

Extinct could be replaced with Extinct (disambiguation) since linguistics might use † to mean an extinct language (I don't know if that's common, but it might be a useful idea if not!)

And this technique could be used for other discrete symbols, even pictures, such as for uncertain classification, whether a listed clade is paraphyletic/monophyletic, and other such potential symbolism.
Whether a listing on the cladogram is excluded or included in the paraphyletic group described by the containing page is already done in {{cladex}} in a fairly self-explanatory way, although I don't know if it would be as self-explanatory or if it works at all for multiple visibly-noncontiguous regions on the cladogram.

An alternative would be to use non-symbolic ways (as seen by the reader) of conveying this information, such as how (I presume!) italics means a leaf species or genus? Colors, highlights, bold, etc. could be used as well as symbols and pictures. But since these can't be a hyperlink, perhaps we could have a key or legend page and a link to this on all clade trees? (ie, put code for a small link in the template)

I would gladly write all the code, but only if the community wishes it, by consensus. So please, give feedback! :)

(P.S. Wikipedia apparently has a bug when unicode characters are entered, in wikimarkup, passed to a string processing function, in a template's source code, which is why the HTML entity is needed on the second † instance, though apparently not the first!)
--RProgrammer (talk) 18:56, 4 June 2016 (UTC)[reply]

The template {{extinct}} is often used to create the dagger character. Peter coxhead (talk) 19:11, 4 June 2016 (UTC)[reply]
Oh, that would make a nice place to insert links and such things!
However, I see it's also unused fairly often. Should we replace usages of the bare dagger with {{extinct}} when we see them? (Having some kind of distinction might be useful, which would only be possible with the template version like a '{{extinctlang}}' and '{{bioextinct}}'(or probably just reinterpreting {{extinct}} to mean extinct biological taxon), unless a whole separate '{{langclade}}' template was made and used for languages, and similarly for other cladograms or an attribute for which type was added.)
--RProgrammer (talk) 19:28, 4 June 2016 (UTC)[reply]
I think that the template is mostly used when editing using a device on which the character is hard to access, such as an iPad (as I am now). I don't see any advantage in replacing the character by the template; indeed, I'd do the reverse.
The problem with any automatic insertion of a link, as per your suggestion above, is that wikilinks should not be repeated in an article (with a few exceptions). See MOS:DUPLINK. So I'm afraid that although your idea is interesting, it has to remain the responsibility of editors to insert a link the first time that appears. Peter coxhead (talk) 19:44, 4 June 2016 (UTC)[reply]

New clade template using Scribunto/Lua module

[edit]

The current clade templates (clade, cladex) have a limited transclusion depth. While this is only a problem for a few larger trees, there is a further problem if you want to reuse a particular phylogeny tree using transclusion to insert a clade from another page. For instance, I have a tree for Passeroidea that goes 16 levels deep and displays successfully. However, if this same tree is transcluded it loses several deep levels and gives an exceeded depth error. This makes it difficult to have larger trees that can be reused on multiple pages.

I have created a new clade template cladeN which uses Scribunto/Lua to process the clade elements. With this template the trees can go deeper and use relatively large transcluded subtrees. For instance, this Passerida tree goes 23 levels deep and includes the above Passeroidea tree by transclusion.

It's only a prototype and, at the moment, doesn't include all the features of the old clade templates (e.g. thickness and dotted lines or as many sister nodes), but they can be added easily enough. The Lua code recreates the tables that make the clade tree using exactly the same wikitext code as the clade template (minus the bits just mentioned).

While big trees might be a minority interest, the code should be easier to manage (e.g. not having to repeat code 17 times for |1, |2 ... |17) and offers potential for extra features in future (e.g. inserting levels with Newick structures). While rudimentary and lacking documentation (the clade template documentation should largely apply), I thought I would mention it now to get some feedback. The module is in the module sandbox: Module:Sandbox/Jts1882/CladeN. Jts1882 (talk) 13:59, 2 December 2016 (UTC)[reply]

@Jts1882: this is an excellent move. I suggest you emulate {{cladex}} which has the maximum number of features – the only reason it has been kept separate from {{clade}} is that it can't quite reach the same depth because of the extra expansions it uses. I don't have time to test your draft right now, but will try to find time over the weekend. Great work! Peter coxhead (talk) 15:11, 2 December 2016 (UTC)[reply]
Baby steps. The templates are new to me and I'd never heard of Lua until a few days ago. I first wanted to exactly replicate the basic tables and I removed the extra features to keep things simple. I've now added a loop so it handles more sister nodes (keeping the 17 maximum). Next I will add back the thickness and dotted line options. I was going to have a look at cladex once the features in clade were working. Jts1882 (talk) 15:27, 2 December 2016 (UTC)[reply]
I've done a further test by modifying the cladogram at APG III system#Phylogeny, which had to be broken into three parts to avoid the depth issue. Using my experimental cladeN it can be displayed in one tree: APG III system. Jts1882 (talk) 15:27, 2 December 2016 (UTC)[reply]
I think all the features in the clade and cladex templates are now working. I've added back the line styling options (thickness, dotted or dashed lines) and also added a colour option. The double line from Cladex is also working. I've made a first pass at the right hand bar/bracket feature from cladex and it appears to work, but it needs some more testing. I'll have a look at the Barlabel for these brackets next. I've used the modified APG III system for angiosperms tree to test the formatting and bracket features (see the malvid section). Adding the brackets doesn't seem to affect the size of the trees.
I'll add that I think the Scribunto/Lua approach is a big improvement for templates. After a short learning curve it's much easier to understand and modify. It took more time to understand the workings of the original clade templates than to learn Lua and implement an experimental template. I think it will be much easier for people to add features in the future. Jts1882 (talk) 11:43, 3 December 2016 (UTC)[reply]
@Peter coxhead: I've added a feature to add subtrees as Newick strings. The variable |newickN overides |N. The Newick parser is rudimentary at present so is very sensitive to the format (especially spaces). A nonsensical example can be found on this test page. On simple tests the Newick tree could go to a depth of 30, but I haven't tested it on more complicated trees. Looking at "NewPP limit report" it is not clear why there is a limit. I've left the debugging depth labels on leaf nodes. Your thoughts would be appreciated. Jts1882 (talk) 20:23, 4 December 2016 (UTC)[reply]
I've tested the Newick feature further and it seems to produce the results correctly. I've tested it by extending the seven lineage Felidae phylogeny tree, using Newick strings to add the species subtrees within the lineages. The tree also makes more use of colouring features. Jts1882 (talk) 15:53, 5 December 2016 (UTC)[reply]
@Jts1882: I've looked through your sandbox tests, and tried some of my own (only via "Preview", not saved). It all seems to work ok as regards replicating {{clade}} and {{cladex}}. When your version is deployed via {{clade}}, then {{cladex}} can simply be made a redirect, I think. Some small points:
  • There's no need for the artificial restriction on 17 immediate children; I would remove it.
  • I think that initially the exact behaviour of the existing templates needs to be reproduced, so "missing" numbered children should not stop later ones being looked at. I've certainly, at least temporarily when fixing incorrect cladograms, relied on being able to edit out e.g. |3= while |4= onwards are still displayed. I wouldn't have intentionally left any like this, but others may have.
  • It would be excellent to get rid of {{barlabel}} and have it all done in {{clade}}. However, I find the labelling method at User:Jts1882/sandbox/templates/Template:APG III system very ugly!
  • Minor quibble from one who spent too many years teaching software engineering to first year undergraduates: writing a == true is redundant to just a; students who wrote if a==true then rather than if a then always got a red correction from me!
Being able to use Newick formulae would also be a great help at times, although I'm not sure how some of the formatting options would then be provided for.
All excellent work, as I said before. Peter coxhead (talk) 09:12, 7 December 2016 (UTC)[reply]
@Peter coxhead: Thanks for the feedback. Some answers to above points and questions.
  • I kept the 17 levels because I was trying to strictly replicate the clade/cladex behaviour.
  • Yes, I was concerned about changing the behaviour. I noted the changed behaviour when modifying one of the tests trees to use cladeN and didn't see the whole tree (I think it was the APG II system tree) and never got around to changing it. However, we need to keep a limit on the number of levels or control the loop in some other way. What higher limit would you suggest?
  • Unfortunately the nested table structure of clade makes it difficult to implement the bar labels within clade because the bars span different tables (inside the bracket might work). They do seem OK when internal to a clade level. However, the bar features replicate cladex in bracketing paraphyletic groups if no label is used.
  • Using Newick structures has advantages and disadvantages. An advantage is that the strings are widely available and easily inserted (although they may need stripping). A disadvantage is that this could encourage laziness. It would be better to use the clade template throughout. The biggest advantage is that they allow deeper trees. They do make formatting more difficult (although in theory it could be replicated in the newick parser), but there was one formatting advantage (see below).
  • I added a styling element to branches (style1 ... styleN) that is useful for providing a background colour that propagated through the HTML table structure, For instance, my Felidae cladogram uses one setting of background-colour for each lineage and this is propagated to nested tables. Unfortunately this can't be replicated for the branch colours and thickness because of a restriction on the way wikitext handles border styling. Annoyingly they have to be set for each level.
  • A way around this is to rewrite the clade template using HTML for the tables rather than wikitext for tables. Lua allows this and, to me, it would make the code more readable. I don't know if this would breach any Wikipedia protocols or common practice.
  • An easy way to propagate the branch thickness and colours is to use a Newick string, e.g. the Pantherinae in my Felidae cladogram.
  • As a general point, what is the best way to proceed? Should I put CladeN in the template and module namespaces so it can have a stable version while I change the sandbox version of the module further? I would have to add some documentation to both the template and module (though I've tried to add helpful annotations in the code). At some point would a good intermediate step be to replace cladex?
  • Any feedback would be appreciated, from Peter or anyone else with an interest. Jts1882 (talk) 13:31, 7 December 2016 (UTC)[reply]

Update and demo of CladeN

[edit]
I've created a demo clade structure which illustrates the features.Jts1882 (talk) 11:05, 8 December 2016 (UTC)[reply]
Template:Clade
Node structure
label1

leaf 1

label2
label A

leaf A

label B

leaf B

 leaf 2 is a nested clade structure
label3

leaf 3

sublabel3
|label1=Node structure  |sublabel1=(brackets)
|style1=background-color:#ffdddd;
|1={{Clade
   |label1=label1  
   |1=leaf 1             
   |label2=label2
   |grouplabel2=&nbsp;leaf 3 is a nested clade structure 
   |2={{Clade |style=background-color:#ffaaaa;
      |label1=label A
      |1=leaf A
      |label2=label B
      |2=leaf B
      |bar1=purple |bar2=purple 
      }}
   |label3=label3 |sublabel3=sublabel3
   |3=leaf 3           
   }}
(brackets)

 

Leaf styling
thicknessN

1 (default)

2

 line thickness

3

colorN

black (default)

red

blue

 #00ff00

stateN

solid (default)

dotted

dashed

 line styles

none

double

|label3=Leaf styling  |sublabel3=(branches)
|style3=background-color:#eeeeee;
|3={{Clade
   |label1=thicknessN
   |1={{Clade
      |1=1 (default) |thickness1=1 |barbegin1=blue 
      |2=2           |thickness2=2 |bar2=blue |barlabel2=&nbsp;line thickness
      |3=3           |thickness3=3 |barend3=blue 
      }}
   |label2=colorN
   |2={{Clade
      |1=black (default) |color1=black          
      |2=red             |color2=red    
      |3=blue            |color3=blue   
      |4=&nbsp;#00ff00   |color4=#00ff00   
      }}
   |label3=stateN
   |3={{Clade
      |1=solid (default) |state1=solid  |barbegin1=purple 
      |2=dotted          |state2=dotted |bar2=purple 
      |3=dashed          |state3=dashed |bar3=purple |barlabel3=&nbsp;line styles
      |4=none            |state4=none   |bar4=purple
      |5=double          |state5=double |barend5=purple 
      }}
   }}
(branches)
node styling
thickness

I

J

K

color

A

B

C

state

X

Y

Z

|label4=node styling  |sublabel4=(brackets)
|style4=background-color:#ffffee;
|4={{Clade
   |label1=thickness
   |1={{Clade |thickness=3
      |1=I  
      |2=J          
      |3=K             
      }}
   |label2=color
   |2={{Clade |color=red 
      |1=A
      |2=B                
      |3=C             
      }}
   |label3=state
   |3={{Clade |state=dashed
      |1=X 
      |2=Y         
      |3=Z        
   }} }}
(brackets)

 

newick
string

((lion,jaguar,leopard),((siberian,bengal)tiger,snow leopard))panthera

subtree
panthera

lion

jaguar

leopard

tiger

siberian

bengal

snow leopard

 expanded Newick string
|label6=newick  
|style6=background-color:#ddffdd;
|6={{Clade
   |label1=string
   |1=((lion,jaguar,leopard),((siberian,bengal)tiger,snow leopard))panthera         
   |label2=subtree 
   |grouplabel2=&nbsp;expanded Newick string    
   |grouplabelstyle2=vertical-align: middle;
   |2={{Clade |style=background-color:#ccffcc;
      |newick1=((lion,jaguar,leopard),((siberian,bengal)tiger,snow leopard))panthera
      |1=Leaf1 (redundant if newick1 set)        
      }}
   }}
paraphyly example 
clade  label a paraphyletic group within a clade
|label7=paraphyly example&nbsp; |style7=background-color:#ffeeff;
|7={{Clade
   |1={{Clade
      |1=[[Geraniales]]          
      |2=[[Myrtales]]            
      }}
   |grouplabel2=&nbsp;label a paraphyletic group within a clade   
   |label2=clade
   |style2=background-color:#ffddff;
   |2={{Clade
      |1=[[Crossosomatales]]         |barbegin1=purple
      |2={{Clade
         |1=[[Picramniales]]         |bar1=purple
         |2={{Clade
            |1=[[Sapindales]]        |bar1=purple 
            |2={{Clade
               |1=[[Huerteales]]     |bar1=purple
               |2={{Clade
                  |1=[[Brassicales]] |barend1=purple
                  |2=[[Malvales]]    |style2=background-color:#ff99ff;
   }} }} }} }} }} }}

A cladogram illustrating clade features.

@Peter coxhead: The trick to the label for paraphyletic groups is to put a label (new grouplabel option) on the last monophyletic parent clade (marked with an "x") that contains the paraphyletic group. This puts the label outside the table containing the bar/bracket. Then create the bar and bracket as before. Vertical alignment can be changed with css styling (vertical-align:top|middle|bottom), but is limited to the top cell. It should work adequately in most cases unless the paraphyletic group is in the bottom half of the parent clade. Jts1882 (talk) 11:05, 8 December 2016 (UTC)[reply]
@Jts1882: looks good! Sorry to be slow and not to respond fully to your points as yet, but inspired by your conversion of this template to Lua, I'm working on converting key parts of the automated taxobox system to Lua. Wow! It took me about half an hour, never having programmed in Lua, to convert something that had taken several days to get right in the template language. Definitely the way to go! Peter coxhead (talk) 16:41, 8 December 2016 (UTC)[reply]
I've written a simple template to convert Newick strings into the clade structure: NewickConverter. This is simply a utilty people can use in their sandbox to build the clade structures.Jts1882 (talk) 18:05, 11 December 2016 (UTC)[reply]
@Jts1882: \o/ awesome Shyamal (talk) 11:23, 12 December 2016 (UTC)[reply]
I've been making a number of test conversions to cladeN. I've copied a number of the large cladograms for the reptiles and birds to my sandbox. With one exception they all worked with no changes (apart from the template name). For example a sequence of large cladograms from basal reptiles though the archosaurs and saurosaurs to birds in general and songbirds in particular. I've also converted some carnivore templates and included a few examples in the wikipedia articles (e.g. Canidae, Felidae and Mustelidae). Jts1882 (talk) 17:20, 27 December 2016 (UTC)[reply]
The one exception was informative. The Neosuchia article has two large cladograms which together are close to the transclusion expansion limit. When I converted these the limit was exceeded. It turns out the new template was about 30% bigger because of the way I did the CSS styling for the tables. Removing styles only used with certain options (e.g. bars and labels) and removing spaces between CSS style elements (these add up when repeated for every row in every clade table) got the template size down. It's now within 1-2%, either bigger or smaller depending on the contents.
@Peter coxhead: I'd like you to have a look and advise on how to continue. I think it's close to being ready. Jts1882 (talk) 17:20, 27 December 2016 (UTC)[reply]
@Jts1882: I'm conscious that I haven't been very responsive; my excuse for the period up to now is, as I wrote above, that I've been working on converting key parts of the automated taxobox system to Lua. It has removed all the massive problems there were with expansion depth, and I continue to be grateful for your example which inspired me.
I'm tied up with holidays for the next day or two, but looking quickly at your tests, it seems to me that there's not a lot more you can do. It's a bit scary when radically changing a widely used template, as I know from experience. But you've proceeded properly, with a lot of tests, so now seems the time to go for it. Peter coxhead (talk) 21:01, 27 December 2016 (UTC)[reply]
@Peter coxhead: Yes, the prospect of making the changeover is a bit scary. I'm fairly confident it is reliable as I started with a strict copy of the wikitext coding and I've tested it on dozens of cladograms. Any problems should be resolvable. I've made some further modifications to the styling to reduce the template expansion size, which is now about 7-8% smaller and should work safely on article pages with large total template expansions. I think I've seen how to reduce it further, but will use the sandbox cladeN module for testing.Jts1882 (talk) 15:06, 28 December 2016 (UTC)[reply]

Conversion to Lua Module

[edit]

I've converted the clade template to use the Lua module. Please report any problems here. Also, as the Lua code is much more flexible, we can also consider new features.Jts1882 (talk) 15:06, 28 December 2016 (UTC)[reply]

@Jts1882: please see the cladograms in Basal (phylogenetics) as examples of apparent problems when {{Phylogeny}} is used in conjunction with the new version of this template. I can't check alll browser/OS combinations, but it doesn't work correctly with Safari under iOS, for example. Peter coxhead (talk) 12:43, 31 December 2016 (UTC)[reply]
@Peter coxhead: The {{Phylogeny}} template is new to me. I gather it is a quick way of nesting a series of successive sister clades. I can't see anything wrong on the Basal (phylogenetics) page. The cladograms seem to match the text description. I checked with Firefox, Chrome and Edge, but I don't have access to Safari. Can you give me a description of the problem. Jts1882 (talk) 13:41, 31 December 2016 (UTC)[reply]
It's a new template to me, too. See here for a screen shot. Usually if it's ok in Firefox and Chrome, which are in different groups of browsers as per Template:Clade#Browser differences, it's ok in all. Odd. Peter coxhead (talk) 16:51, 31 December 2016 (UTC)[reply]
I read the old discussions on the differences between Chrome and Firefox, so I was surprised to see that Chrome and Firefox display the same way (at least on Windows 10). It seems that Chrome may have changed how they render HTML tables. Your screen shot looks like the old Chrome. As a general question, do you generally use Safari? I've been concerned that I haven't been able to check this as I don't have any Apple products.
The phylogeny template is an old one. It was created in 2008 and had a few trivial edits in 2013. I wonder how often it is used. Is there a way of checking the pages a template is used on?
The Basal (phylogenetics) page doesn't even use it for the purpose it is intended (automatically making successive nestings) as it just deals with two sister clades handled with the clade template. I don't see why it was used at all instead of just using clade. The problem may come from the nodes not being number. But as the template just treats the passed parameters in order passed as |1,|2,etc., I don't see why this should be a problem.
I'll have to think on this. Jts1882 (talk) 17:40, 31 December 2016 (UTC)[reply]
I normally use Firefox on a Mac laptop, but right now only have access to Safari on an iPad. Your tests all looked fine on the combinations I checked prior to the new version being made live. I'll look again when I am back to my laptop. All the demos of CladeN look fine on my iPad, so I think it is an issue with the phylogeny template.
If you go to a page, then to "What links here" in the left-hand column, you can see uses and choose to see transclusions. The phylogeny template has very few, and I'm inclined to replace them by straight uses of clade on the grounds that it doesn't display correctly in all browser/operating system combinations. Peter coxhead (talk) 18:20, 31 December 2016 (UTC)[reply]
@Peter coxhead: Yes, replacing the existing instances of the phylogeny template seems the simplest solution. Although I would like to understand why there is a problem, as this could prevent future issues or provide clues about how the improve the appearance in Safari and other browsers using that rendering method. Unfortunately, I can't test on Safari. Perhaps you can help by checking if you see the same problem on these pages that use the phylogeny template: Anthophyta, Euthycarcinoidea. Jts1882 (talk) 09:53, 1 January 2017 (UTC)[reply]
Ok, progress.
  • At least under MacOS, the information at Template:Clade#Browser differences is wrong: both Chrome and Opera now use the same algorithm as IE and Firefox; only Safari of the browsers I can check is out of step.
  • The issue only seems to arise when the nesting is {{clade|{{phylogeny|...}}}}, which it's not at Anthophyta and Euthycarcinoidea. However, this isn't the proper syntax for {{clade}}: it should be {{clade|1={{phylogeny|...}}}}. When I changed to this, the problem went away. (What I haven't tried to understand is why it worked before without the 1=.)
Peter coxhead (talk) 10:35, 1 January 2017 (UTC)[reply]
I hadn't realised until yesterday but you can use clade without the numbers, it just treats them in order, e.g. {{clade |leaf A |leaf B |leaf C }} produces the expected tree. As you say, it's when the {{phylogeny}} template is inserted that there are issues. Do you know if those examples in the Basal (phylogenetics) page were displaying correctly before the change to Lua? Jts1882 (talk) 11:42, 1 January 2017 (UTC)[reply]
Ah, solved it. I should have realized that {{clade |leaf A |leaf B |leaf C }} is (more-or-less) equivalent to {{clade |1=leaf A |2=leaf B |3=leaf C }}. The "more-or-less" is because the second form trims leading and trailing white space; the first does not. Thus "{{1x| this }}" → " this " but "{{1x|1= this }}" → "this". {{Phylogeny}} was producing an initial return character, which was causing the problem when it was not removed by {{clade|{{phylogeny|...}}}}. I've fixed {{phylogeny}} now, so it should all be ok. It's good practice to use the form {{clade|1=...}} rather than {{clade|...}} precisely because it trims the input. Peter coxhead (talk) 13:44, 1 January 2017 (UTC)[reply]
Excellent news. I was playing with examples with and without numbers, but couldn't work out the subtly different behaviour on branch positions. Now it seems to make sense. That is a relief. I agree that not using the numbers should be discouraged, as it also aids readability. A large nested structure without numbers would be difficult to understand. Jts1882 (talk) 14:21, 1 January 2017 (UTC)[reply]

Green on black skin

[edit]

A compatibility issue with the Green on black skin, the border color is set to black (nodeColor). Please leave this blank so the browser uses the default color (the text color). — Dispenser 03:45, 13 February 2017 (UTC)[reply]

The way the clade structure is drawn using HTML tables requires the CSS to be overriden for border properties. The "kludge" appears to work, though. I can't see any problems with the examples I checked. An alternative might be to default to the "inherit" keyword (instead of black or "") when setting the nodeColor and branchColor parameters and then the kludge could be omitted.
As a further issue, is the goal to have a monochrome output for the visually impaired? If so it might be possible to disable some of the styling options (colour lines, background colours) if the skin is being used. This would need some way of detecting the skin or a CSS class from within LUA. Jts1882 (talk) 11:01, 13 February 2017 (UTC)[reply]
The style inspector indicates "inherit" on border: will clobber border-style and border-width per the spec. If we use border-color:inherit; it would support * { border-color:magenta } instead of using the color text which is interesting, but in this case I think we want it the same as the text color.

My overall goal is to support night mode color schemes, while allowing colors. If I wanted monochrome * { border-color:#00dd00!important; } works well enough. — Dispenser 16:57, 13 February 2017 (UTC)[reply]

The whole use of inline styles is an abomination and makes it impossible to write user styles without resorting to using !important. At the very least the clade table needs its own specific identifying class so it can be targeted without creating overriding rules for every table on Wikipedia. .clade would work fine. I'm a frontend dev and user of a dark theme but using a style sheet from userstyle.org. Chic happens (talk) 12:40, 22 February 2018 (UTC)[reply]

I did look into using the templatestyles extension to replace all the table border inline style elements with classes in the clade template, but then discovered this is not implemented on Wikipedia.   Jts1882 | talk  16:15, 22 February 2018 (UTC)[reply]

Compatibility with Cladex template

[edit]

@Jts1882: The Lua version of {{Clade}} seems to work well and there haven't been any reported problems. So I thought that since it supports the features of {{Cladex}}, the latter could be replaced by a redirect to {{Clade}}. However, consider the two cladograms below. The first uses {{Cladex}}, the second has every occurrence of {{Cladex}} replaced by {{Clade}}. There might be browser/operating system differences, but with Firefox, Safari and Opera on MacOS, the first cladogram is displayed correctly (the right hand vertical bars all line up), the second is not. (I added two nonbreaking spaces after "Blosfeldia (Blossfeldieae)" to show more clearly that the vertical bar here shifts to the right, but they aren't necessary for the effect to occur.) Peter coxhead (talk) 10:50, 27 March 2017 (UTC)[reply]

Cactaceae

Pereskia A

Pereskia B

Maihuenia

incertae sedis

Cylindropuntieae

Opuntieae

Blosfeldia (Blossfeldieae)  

Cacteae

incertae sedis

Phyllocacteae

Rhipsalideae

Notocacteae

Cereeae

Cactaceae

Pereskia A

Pereskia B

Maihuenia

incertae sedis

Cylindropuntieae

Opuntieae

Blosfeldia (Blossfeldieae)  

Cacteae

incertae sedis

Phyllocacteae

Rhipsalideae

Notocacteae

Cereeae

@Peter coxhead:They clearly behave differently and there is a browser difference. I don't see the problem after Blosfeldia without the two spaces (Firefox, Win10), but I get the problem if I add a few extra spaces. The Blodfeldia cell becomes longer than its sister clade. It can be fudged by putting spaces after the longest name in the latter clade (i.e. after Notocacteae).
A better illustration of the difference is the central purple bracket, which isn't aligned with the others. The Lua clade aligns the bars (i.e. last cell RHS) differently, the cladex template aligns them all together. It's as if the alignment of the right of the table cell is handled differently, with cladex stretching the table cell to the end of the table row, and the Lua clade leaving space in the table row without a table cell. The following scheme tries to illustrate this:
cladex rows:
____| AAA | BBB | CCCCCC |
____| XXX | YYY | ZZZ           |
Lua clade rows:
____| AAA | BBB | CCCCCC |
____| XXX | YYY | ZZZ |
The label bars were always an unsatisfactory part of the Lua module. Now I think about it could also explain why the coloured clades don't always align at the right [Edit: now illustrated in your cladograms]. If we can work out the difference we can fix that as well. Jts1882 (talk) 12:29, 27 March 2017 (UTC)[reply]
I think the difference is in the use of "style="width:100%;" in the table definition in cladex. It isn't used in clade. When I add it to the Lua clade, the bars and background colours align, but the table is full page width (not desirable). Looking at the HTML for the cladex cladogram, the width styling is only inserted in some tables (e.g. not the outer one). I'm trying to understand why, as this seems important to stop the cladogram going full width. Jts1882 (talk) 14:27, 27 March 2017 (UTC)[reply]
I missed something. Your cladex cladogram uses clade for the first two clade statements. This is essential to prevent the cladogram stretching to full page width. Change both to cladex and the cladogram stretches to full page width. Change only one and it doesn't (wierd). But cladex uses width:100% for the rest of the internal clade structures, which aligns the RHS of the cells. The question is how to reproduce this in Lua clade.Jts1882 (talk) 14:47, 27 March 2017 (UTC)[reply]
Yes, the outermost clade is important; see the third bullet point at Template:Cladex#Debugging. There's always been a lot of trial-and-error in coding these templates! Peter coxhead (talk) 14:59, 27 March 2017 (UTC)[reply]
Ah, that was something about cladex that I had totally missed. I think that means that cladex can be converted to the module with the following code {{#invoke:Clade|main|style=width:100%;{{{style}}} }}.
More generally, the cladex behaviour is preferable when using bars and labels. I wonder if a change to add width:100% whenever a clade structure uses any of bar/barbegin/barend would work. The difficulty is they are applied to each leaf rather than whole brackets. Alternatively, this is useful knowledge going forward and width:100% can be added as needed to aid constructing the bars (as below).
Cactaceae

Pereskia A

Pereskia B

Maihuenia

incertae sedis

Cylindropuntieae

Opuntieae

Blosfeldia (Blossfeldieae)  

Cacteae

incertae sedis

Phyllocacteae

Rhipsalideae

Notocacteae

Cereeae

Very cumbersome, but an option that can be used without any changes to the template. Jts1882 (talk) 06:51, 28 March 2017 (UTC)[reply]

Extra blank lines above and below

[edit]

There was an issue with {{Clade}} that was related to a similar strange piece of behaviour being discussed at Template talk:Taxobox#Why are we wrapping the infobox inside a div?. It has now been fixed as per the discussion below.

Consider the following:

Here's a paragraph of text followed by one blank line, as usual.

Here's a simple cladogram produced by {{Clade}}

Here's another paragraph of text with one blank line above it, as usual.

After applying a partial fix, what I now see is two blank lines above the cladogram. If you look at the HTML generated by the MediaWiki parser, you see <p><br /></p> has been generated above the the <table> tag. This does not happen with {{Cladex}}:

Here's a paragraph of text followed by one blank line, as usual.

Here's a simple cladogram produced by {{Cladex}}

Here's another paragraph of text with one blank line above it, as usual. Changing {{Clade}}, as I have at {{Clade/sandbox}} seems to remove the problem:

Here's a paragraph of text followed by one blank line, as usual.

Here's a simple cladogram produced by {{Clade/sandbox}}

Here's another paragraph of text with one blank line above it, as usual.

Peter coxhead (talk) 19:49, 2 May 2017 (UTC)[reply]

An interesting behaviour. My first question was why is the behaviour different with {{Cladex}}? As the discussion of the reason mentioned text wrapping, I wondered if it was related to the styling with "width:100%;" in cladex. This doesn't seem to be the case when I tested the change in the module. Could the difference be due to the use of the invoke method with the module or the noinclude statement in front of it?
The line after the cladogram can be removed by removing the linebreak in the template before the noinclude statement for the documentation. But removing the noinclude before the invoke statement doesn't remove the extra line before the cladogram.Jts1882 (talk) 09:24, 2 May 2017 (UTC)[reply]
Looking at some of my test pages I can now see the extra spacing was always there. Curiously it doesn't occur if immediately following a section heading, when the cladogram looks too close to the heading. I actually think the extra spacing looks better (at least more familiar). Which brings me to the second question, is it something that needs fixing? The div wrapper will be added to all the tables which adds quite a lot of overhead to the template size for large cladograms. I remember the difference all the spaces I'd added to the styling when I wrote the Lua module made to the template size and how it caused some pages to fail.
That said, I don't feel strongly about this either way. The lines above and below can also be removed with {{Clear}} statements, which could be used for customising individual pages if the work-around isn't used. Jts1882 (talk) 09:09, 2 May 2017 (UTC)[reply]
It definitely seems to be a difference in invoking the template using the module. I did a test where cladex was converted to use the module with {{#invoke:Clade|main|style=width:100%;{{{style}}} }} and the extra lines were introduced as with clade. Jts1882 (talk) 16:29, 2 May 2017 (UTC)[reply]
@Jts1882: several points:
  • Yes, it's something that must be fixed. I've seen editors omitting blank lines between text and a cladogram to avoid the extra blank lines, and this is wrong. I've been using {{cladex}} as the outermost template for the same reason, and this is also wrong. Nor should the addition of clear statements be needed.
  • Yes, the extra blank line above and below have different causes. The one below is because the live version wrongly included a return before the second <noinclude>; I've removed it now and the extra line below disappears. I've revised the tests above accordingly.
  • The extra line above turns out to be a known bug in the WikiMedia parser, discussed in detail at T18700. It's not specifically to do with invoking a module – it happens whenever a nested template builds a table with wikitext syntax. If the outermost template builds the table it works fine, but apparently the parser loses track of being at the start of a line when expanding inner templates and inserts an extra blank line.
  • Kaldari has reported a better way to work around the bug rather than use a div, which was the only work-around used previously. I've applied this to {{Clade/sandbox}} and, as you'll see above, the problem is fixed without the need for a div. I see no reason not to apply this fix to the live version, but I'll leave it for a day because discussion of the fix may not have finished at Template talk:Taxobox#Why are we wrapping the infobox inside a div?
Peter coxhead (talk) 19:43, 2 May 2017 (UTC)[reply]
My only issue was increasing the total expansion size for templates, which is close to the limit on a few pages with large cladograms. The nowiki tag doesn't add to the output so I see no downside to this change.Jts1882 (talk) 12:35, 3 May 2017 (UTC)[reply]
Ok, we agree; now fixed in the live version. Peter coxhead (talk) 16:18, 3 May 2017 (UTC)[reply]

"Reverse clade" options?

[edit]

Is there a way to do a reverse clade? I've seen this tool used to show companies merging but not splitting up. For example, AOL merged with Time Warner but then they split - is there a way to represent that as a clade? Timtempleton (talk) 23:05, 12 June 2017 (UTC)[reply]

No, there is no way of displaying splits and mergers using clade and I can't see an easy way of implementing such a feature. What may suit your purpose is the template {{chart}} which can construct family trees with ancestors and descendants. An overview of family tree options on Wikipedia can be found in Wikipedia:Family_trees. As long as you don't mind a vertical tree structure, the chart template looks the most suitable. Jts1882 (talk) 07:42, 13 June 2017 (UTC)[reply]
Thanks for the tip - I'll check it out. Timtempleton (talk) 00:34, 14 June 2017 (UTC)[reply]
@Timtempleton: If you haven't seen it by now, {{cladeR}} now exists. The documentation shows the opposite of what you want, but you should be able to reverse the display by reversing the logic like this... but it doens't quite align properly. @Jts1882:? - UtherSRG (talk) 12:32, 21 September 2022 (UTC)[reply]

 

 

 

 

 

 
 
Panthera

snow leopard

tiger

jaguar

lion

leopard


@UtherSRG: - Thanks for the ping. Good to know. TimTempleton (talk) (cont) 13:45, 21 September 2022 (UTC)[reply]

Error messages

[edit]
Physeteroidea
Raptors

I made this cladogram and it keeps throwing up error messages saying there's more than one |1= and |2= but I can't find it, and all the terms are showing. Also the blue bar keeps scrambling up in mobile view. Send help, thanks   User:Dunkleosteus77 |push to talk  15:58, 22 November 2017 (UTC)[reply]

@Dunkleosteus77: I've fixed the cladogram – the version now above is correct. The error messages came because you had stray "|" characters after some occurrences of "clade". (This causes an error because, ignoring line breaks, {{clade||1=X}} has the same meaning as {{clade|1=|1=X}}. Numbering the parameters makes them easier to check, but {{clade|1=X|2=Y}} produces the same output as {{clade|X|Y}}.)
As for the second problem, this isn't fixable – at least I don't know how to do it. The mobile view lays out the cladogram differently (as does print view), so the bars generated by {{cladex}} don't fit. Now people use mobile view more often we probably shouldn't be using the "bracketting" {{cladex}} can produce, which is a pity. Peter coxhead (talk) 17:02, 22 November 2017 (UTC)[reply]
thanks, hopefully one of these days we can figure out the bracketing, it’s rather useful for grouping   User:Dunkleosteus77 |push to talk  17:18, 22 November 2017 (UTC)[reply]

Template-protected edit request on 17 April 2018

[edit]

Please add {{subst:tfm|Cladogram}}, then set the correct |link= parameter, per a nomination by Chicbyaccident. {{3x|p}}ery (talk) 15:11, 17 April 2018 (UTC)[reply]

Was already done. — xaosflux Talk 17:52, 17 April 2018 (UTC)[reply]

Collapsible clade elements

[edit]

Is it desirable to have collapsible/expandable clade elements? Earlier browsers had mixed behaviour when elements were hidden, some collapsed the space, some left the space blank. The latter was clearly undesirable. Newer browsers are more consistent in their handling and using the mw-collapsible extention seem to behave the same (I've checked Chrome, Firefox, and Edge on Windows).

Demo. Using {{clade hidden}} with collapsible element (initially hidden)

root

Standard leaf

Hidden clade

Leaf1

Leaf2


Any thoughts?   Jts1882 | talk  09:19, 26 June 2018 (UTC)[reply]

Looks like a useful feature to have. Would be nice to be able to set the default state. Shyamal (talk) 09:33, 26 June 2018 (UTC)[reply]
The template is a stripped down version of {{hidden}} so the additional parameters can easily be added back. I just created it as a test of principle and to see if it was a good feature to add. There might be issues with how different (especially older) browsers handle it that make it unacceptable. This is something that has plagued the clade template in the past, although the compatibility is much better now.
I wasn't thinking it would be something used extensively (e.g on every node), but more an occasional addition for large cladograms to hide large subclades and make it easier to see the higher order structure.   Jts1882 | talk  10:33, 26 June 2018 (UTC)[reply]
Yes, I understand your point. I just tried the download PDF option and I am pleasantly surprised to see how the cladograms looking in print. Shyamal (talk) 10:43, 26 June 2018 (UTC)[reply]
Amphibia

Gymnophiona (caecilians)

Batrachia

Caudata (salamanders)

Anura (frogs)

Here is a more elegant looking update template.
This works by inserting a one-row, three-cell table on the branch (|2=), each cell containing a collapsible element (⊞, {{clade}}, ⊟). The plus and minus elements toggle all three elements.   Jts1882 | talk  06:48, 27 June 2018 (UTC)[reply]

Update.

I have implemented the hidden capability in the Lua module and added a few parameters to make it more flexible. Here are three examples and a brief explanation.

Amphibia

Gymnophiona (caecilians)

Batrachia

Caudata (salamanders)

Anura (frogs)


Amphibia

Gymnophiona (caecilians)

Batrachia

Caudata (salamanders)

Anura (frogs)


Amphibia

Gymnophiona (caecilians)

Batrachia
⊞ [expand clade]

Caudata (salamanders)

Anura (frogs)

[collapse clade]


  • |expanded=true (set to get the initially expanded state; the default is hidden state)
  • |mode=left/right (position of collapse "button" i.e. on the node or outside)
  • |expand-symbol= (set the symbol or text for expand action; default: ⊞)
  • |collapse-symbol= (set the symbol or text for collapse action; default: ⊟)
  • |id= (set an id for the collapsible element so they behave independently; use the same id for elements that should collapse/expand together; with no id all elements will collapse/expand at the same time)

@Peter coxhead, Shyamal, and IJReid: Any comments? An example of the cases where it might be useful is the APG IV system#Phylogeny which would be much more managable with four main clades collapsed (see example). Some of the larger reptile/dinosaur cladograms could also benefit.   Jts1882 | talk  10:08, 29 June 2018 (UTC)[reply]

I recently stumbled upon this and I love it! But it leads me to a new possibility... Can we have a "clade swap" notion? When you expand clade A, it automatically collapses clade B? This would allow displaying alternate phylogenies in one interactive diagram. For instance, clade A could be one arrangement of families, leading to various genera, while clade B is a different arrangement of those families. I know we can show alternatives with {{cladeR}}, but that really only works if the leaf nodes align. Another option I'd like to see is the ability to pass in the open/close parameters via a parent clade. This would allow setting the majority of the cladogram in a single template that is used across multiple articles, but with different initial parameters controlling how it is initally displayed. (Similar to how some multi-box nav boxes are varyingly displaying none or one or more levels.) Anyway, great work (as late as this thanks is! :D ) - UtherSRG (talk) 18:32, 20 September 2022 (UTC)[reply]
A major problem with collapsible elements is they don't work on mobile (or didn't). They just appear expanded. So while I like the idea of using this feature, I'm unsure if it's good to have something that won't be working for a lot of readers.
The template {{clade hidden}} has parameters |expand-text= and |collapse-txt=, which can be used to change the display. If you put a cladogram in one of these parameters it might work. The test below is messed up by the position of the symbol above the alternative clade
root

Unhidden Leaf

swappable clade

A

B

Leaf1

Leaf2

  click to toggle  
This might be fixable by removing the symbol, although then it would need some way of toggling the display. —  Jts1882 | talk  15:07, 21 September 2022 (UTC)[reply]
@UtherSRG: The example now works crudely with the external toggle. —  Jts1882 | talk  15:36, 21 September 2022 (UTC)[reply]
Yeah, I just downloaded the mobile app, it still auto-expands everything. :( But still, your example is not what I'm looking for. Lemur#Taxonomic classification and phylogeny has two competing phylogenies. I'd like to have a whole Primates clade that includes everything from Order to Genus. But which lemur phylogeny to use? I want both, with a button to swap between (or among in cases where there are 3 or more) different phylogenies. But given that it still doesn't work with mobile... I understand and appreciate your hesitancy to do any work on this. (If you were wondering how I'd handle the clades past the swap, I was figuring to use the subclade feature, putting each of the lemur families as subclades, and the swappable clades would point to the subclades.) - UtherSRG (talk) 15:37, 21 September 2022 (UTC)[reply]

Oh... I see... A/B is one phylogeny, and Leaf1/2 is another phylogeny. Hrm..... - UtherSRG (talk) 15:46, 21 September 2022 (UTC)[reply]

  click to toggle  
Lemuroidea 

Daubentoniidae

Lepilemuridae

Cheirogaleidae

Lemuridae

Megaladapidae

@UtherSRG: Isn't the above a crude version of what you want? —  Jts1882 | talk  16:02, 21 September 2022 (UTC)[reply]
Yes, though I plan to have it embedded in a larger tree that would hide that whole clade depending on level. So awesome! Thanks! - UtherSRG (talk) 16:57, 21 September 2022 (UTC)[reply]
I have the larger structure started in my sandbox. - UtherSRG (talk) 17:01, 21 September 2022 (UTC)[reply]
I have some examples of the use of interactive clades in large phylogenies at Birds, Snakes & Lizards and Flowering Plants. I've also started work on something for selective transclusion, see {{Clade_transclude}}, which has some limited options for hidden elements. —  Jts1882 | talk  19:17, 21 September 2022 (UTC)[reply]

Documentation update

[edit]

Now that Jts1882 has successfully merged {{cladex}} into {{clade}}, the documentation for the template needs updating. I made a quick start, but it needs more work. For example, there's no need for Template:Clade/doc/common now, and it needs the options to select a version removed and to be moved to Template:Clade/doc. Peter coxhead (talk) 07:32, 1 August 2018 (UTC)[reply]

Non-breaking hyphens

[edit]

One of things that Module:Clade does to a string before displaying it, is replacing hyphens with non-breaking hyphens (this is done on one of the last lines of the function p.addLabel). There are probably good reasons for doing that, but it creates a problem if the label to be displayed is a link (which happens relatively often when used in articles about language families). See for example the clade here: the link to Austro‑Tai is red not because the article doesn't exist, but because it exists at a title with a normal hyphen: compare Austro‑Tai languages (non-breaking hyphen) with Austro-Tai languages (normal hyphen). This doesn't happen with non-braking spaces for example: as far as I'm able to see, the Mediawiki engine treats them as equivalent.

So what is the solution? Maybe it would be nice if the Mediawiki software were changed so as to treat hyphen and non-breaking hyphens as equivalent in titles, but that's beyond us. Another approach is to have piecemeal fixes for each individual case, like replacing hyphens with n-dashes (stylistically, this works in many cases, but I'm wary of having a technical glitch force a stylistic rule across the board), or creating a redirect for each title with a non-breaking hyphen (that's a tall order, and such redirects are likely to get deleted: see this ongoing RfD).

A simpler solution is to change the module, so it doesn't replace hyphens with non-breaking hyphens. Is this going to lead to problems? If yes, an alternative is to take advantage of the fact that in most cases the links concerned tend to be piped: [[Austro-Tai languages|Austro-Tai]]. With a bit of extra code added to the module, it should be able to detect such piped links and make the hyphen replacement only in the displayed text to the right of the pipe, leaving the link intact. – Uanfala (talk) 13:14, 25 March 2020 (UTC)[reply]

Regular hyphens cause a problem because line breaks in labels break the lines of the cladogram. I've never been entirely sure why and suspect there is a better solution, but it has proved elusive.
Adding no wrap spans to all labels greatly increases the size of some large cladograms. The space used to be changed to a non-breaking space, but that is now handled by the CSS whitespace attribute. Unfortunately there is not similar fix for the hyphen.
I think your suggestion of checking wikilinks with a pipe is a possibility. There is already a check for strip markers. So something like don't replace if the label contains string.find(nodeLabel, "[[.-|.-]]") (with escaping).
I've made a temporary fix by putting the label in a span element, which causes addition of a nowrap element, but this whole no wrapping in labels needs a better solution. That p.addLabel function is in need of a revamp. —  Jts1882 | talk  15:40, 25 March 2020 (UTC)[reply]
@Uanfala: The non-breaking hyphens are no longer added to wikilinks. I've reverse the temporary fix. —  Jts1882 | talk  12:49, 27 March 2020 (UTC)[reply]
There seems to be a problem with hyphens in trees. Any ideas? For example in the tree in Faboideae#Systematics, I cannot get the link Inverted repeat-lacking clade to work. kupirijo (talk) 12:15, 27 March 2020 (UTC)[reply]
Kupirijo, yep, that's the same issue. Jts1882, I don't much understand HMTL or the module, but it seems to me that the nowrap solution, which appears to be used when styling elements are detected, can be naturally extended to hyphens. When it checks for style elements, the module can also check for hyphens (or other potential problematic characters like n-dashes). I don't think this will greatly affect the size of the cladograms given that hyphens tend to be present only in a minority of entries. The other solution – replacing with non-breaking hyphens only if links are not present – is not optimal, because then the original problem with line breaks will come back again. Given that most entries in a cladogram tend to be wikilinked anyway, this means that the solution with the non-breaking hyphens will only work in a minority of cases. – Uanfala (talk) 12:46, 27 March 2020 (UTC)[reply]
Good idea. That is a better solution and should also handle the strip markers. I'll implement that when I clean up that function more thoroughly. —  Jts1882 | talk  12:55, 27 March 2020 (UTC)[reply]
(edit conflict)
@Kupirijo: The code was replacing a hyphen without a non-breaking hyphen as line wrapping can break the cladogram table structure. I've now checked for wikilinks and it no longer makes the replacement. The Meso-Papilionoideae and IRLC links now work at Faboideae#Systematics. —  Jts1882 | talk  12:49, 27 March 2020 (UTC)[reply]
@Jts1882: Thank you! And also thank you for fixing the bean-tree! kupirijo (talk) 15:36, 27 March 2020 (UTC)[reply]

Cladogram changing

[edit]

I think that:

should be changed to:

because all the other birds are considered Neoaves. EinesteinNobel (talk) 03:57, 30 August 2024 (UTC)[reply]

 Done. I've also removed Craciformes as that hasn't been used for ages.  —  Jts1882 | talk  05:49, 30 August 2024 (UTC)[reply]

Whitespace around labels

[edit]

I've noticed several clade diagrams have HTML entities like &nbsp and &emsp at the beginning and end of labels to prevent the vertical lines from being too close to the words. I've been removing them on the theory that taking up less horizontal space is better, but this was reverted in at least one case Special:diff/1258412212 by Cougroyalty. If this space is desirable, I think it would be a lot cleaner and more consistent if it was added by the module rather than having to add it on every page that uses the module. -- Beland (talk) 17:19, 19 November 2024 (UTC)[reply]

I agreeing doing it through the template would be better for consistency. The template uses WP:TemplateStyles and does add a small amount of CSS padding (0.15em) on the label. More padding would be desirable on many simple cladograms, but the problem is that it's not always desirable. There are many large cladograms where horizontal spreading is an issue due to long taxon names, especially with the new skins where overflow into the margins is problematic. In many cases the HTML space entities will have been added before the CSS styling was added through TemplateStyles so adding more automatic spacing would add to that already there. We have to consider backward compatibility. I'll try and do a few tests and look at a bit more automatic padding. A search to find how often these spaces entities are used might also be helpful.  —  Jts1882 | talk  18:12, 19 November 2024 (UTC)[reply]
I wouldn't worry about backward compatibility; I can run a script to semi-automatically remove HTML entities if we're increasing the CSS padding. I've just kicked off a database scan to see how often this happens. Do you have an example of a large diagram that has problematically long names? We could make those multi-line if there's room. -- Beland (talk) 00:09, 20 November 2024 (UTC)[reply]
It looks like there are about 1570 articles using {{clade}} with HTML entities in at least one label value (including the articles I've just removed the entities from). That should be feasible to clean up in a day or two, if we decide to go ahead with that. I can share the list of articles if anyone finds that useful. -- Beland (talk) 00:24, 20 November 2024 (UTC)[reply]
@Cougroyalty:. How much space at the ends of the label do you think is necessary? I think the em-space (" ") in the Crocodilia is excessive. Incidentally, if you want to set the length of the labels for alignment, there is a |length= parameter.  —  Jts1882 | talk  11:49, 20 November 2024 (UTC)[reply]
OK, I did some testing with some spaces. I agree that the em-space (" ") is a bit excessive, but can be nice in a small simple cladogram. I tried with a single nb-space (" "), and I think that looked fine. I think a good example of the spacing issue is if you compare diffs at Crocodilia, and in the cladogram specifically look at Alligatoridae and Longirostres. Without the spaces, they just look so cramped. Also, if you look at the unnamed subclades within Crocodylidae, they also look cramped without any spaces. You can even see in the cladogram example directly above this section of the talk page, they added nb-spaces (" "). Maybe there is a way this clade template can just automatically add a single leading and ending space for each line? Cougroyalty (talk) 16:23, 20 November 2024 (UTC)[reply]
I believe a non-breaking space is one en wide, so adding that would be the equivalent of adding .5 em in CSS instead of or in addition to the current .15 em. -- Beland (talk) 18:46, 20 November 2024 (UTC)[reply]
I think the non-breaking space is too large for the default. I've increased the padding to 0.25, which I think gives adequate spacing without stretching some of the larger cladograms. Is this sufficient or should it be increased a bit more?
As an alternative to using lots of spaces, the |length= parameter can be used to increase the spacing and to align labels and terminal taxa. As an example, I edited Crocodilia with Special:diff/1258741340. I've reverted the change as it was for discussion purposes.  —  Jts1882 | talk  10:38, 21 November 2024 (UTC)[reply]
I've started removing &nbsp and &emsp from the articles using this template, on the assumption that the built-in padding is now adequate (or could be increased in the future if anyone wants) and that consistent appearance is desirable. -- Beland (talk) 23:37, 30 November 2024 (UTC)[reply]
I'm also removing nbsps between words and the advice to use them; this should be taken care of by "nowrap" CSS added as noted in the #Non-breaking hyphens thread. -- Beland (talk) 03:27, 5 December 2024 (UTC)[reply]

Whitespace around vertical bars and leaf text

[edit]

Template:Clade/doc#Adding vertical bars and brackets recommends using a non-breaking space to avoid text colliding with vertical bars. This should just be done in CSS to make the template call easier to read, and so this spacing can't be forgotten. I'm removing non-breaking spaces from all using articles at the moment (to avoid double-padding as mentioned in the thread above). It's difficult to systematically distinguish between padding that would be extra vs. needed, so the padding that's currently needed (but shouldn't be) is going away.

While we're adding padding to the right of leaf note labels, it might be nice to add some to the left as well, as they are awfully close to the horizontal lines that lead to them. -- Beland (talk) 03:18, 5 December 2024 (UTC)[reply]

Unfortunately I don't see how adding space before the vertical bars can be done in CSS. The obvious thing is to add similar padding to that used for the labels to the terminal text. However, because of the way the system uses nested tables to build the cladogram lines, this padding would separate the tables and add gaps in the cladogram lines.
On the labels, the same padding (0.25em) is added to the left and right of the labels. Edit. Oh, I think I misunderstood, you mean to the left of terminals. This is the same answer as above to separate the vertical bar. It will add gaps to the cladogram structure. We need a soution where the padding is only added to terminals and not when another clade template, i.e. when |1=taxon name and not |1={{clade ...}}.  —  Jts1882 | talk  08:03, 5 December 2024 (UTC)[reply]
I found a solution and implemented it - add padding to the p element under classes clade-leaf and clade-leafR. -- Beland (talk) 09:16, 5 December 2024 (UTC)[reply]
That looks a good solution. I was looking for a way to distinguish terminals and nested templates. That p element is added by the Wikimedia software when a table cell has plain text. I checked the other skins and mobile and they all behave the same way.  —  Jts1882 | talk  09:51, 5 December 2024 (UTC)[reply]

Vertical text to save horizontal space

[edit]

I was thinking some vertical text might help narrow some wide clade diagrams. I have created {{vert-label}} to use for this purpose. As an example, I've used it on the last clade diagram on Diapsid#Relationships.

BTW, another solution to prevent horizontal scrolling in a lot of cases might be to draw the diagrams from top to bottom instead of left to right. -- Beland (talk) 08:32, 5 December 2024 (UTC)[reply]

Not sure I understand. The labels would still have the same width, regardless of the order. Also the output when doing the cladograms top to bottom is supposed to be very ugly on Apple devices.  —  Jts1882 | talk  11:22, 5 December 2024 (UTC)[reply]
Just because the words have the same width doesn't mean the overall diagram has the same width, because they are arranged differently. For example, below, A is wider than B:
A.)
                  --- Species number one
Clade number one  |
------------------|                  --- Species number two
                  | Clade number two |
                  -------------------|                    --- Species number three
                                     | Clade number three |
                                     ---------------------|
                                                          |
                                                          --- Species number four
B.)
              | Clade number one
        -------------
        |           |
Species number one  | Clade number two
                    |
           ---------------
           |             |
 Species number two      | Clade number three
                         |
                      -----------------------
                      |                     |
            Species number three   Species number four
Not sure what you mean by "supposed to be ugly", but the appearance should be more or less the same across browsers if CSS is used correctly. -- Beland (talk) 17:09, 5 December 2024 (UTC)[reply]

Line wrapping in example code

[edit]

Some of the examples in Template:Clade/doc would look better if {{clade example}} set "white-space: revert;" on the "pre" tag it's wrapping code in, but this is hidden in the guts of a Lua module and I'm not sure how to do that. I'm also not sure if the "pre" is really needed if there's a "syntaxhighlight" there. -- Beland (talk) 09:35, 5 December 2024 (UTC)[reply]

I'm note familiar with "white-space: revert;". What does it do? I tried adding it to the table cell CSS and saw no difference. Where should I use it?
@Jts1882: "revert" is explained (supposedly) here, but it's beyond my understanding of CSS. Peter coxhead (talk) 16:59, 5 December 2024 (UTC)[reply]
The syntaxhighlight was added to some of the examples relatively recently. The "pre" is needed for older uses. I did try using syntaxhighlight instead of pre in the module. I can't remember what happened, but commented out the change which suggests it didn't work and that I planned to revisit it.  —  Jts1882 | talk  11:34, 5 December 2024 (UTC)[reply]
From what I can tell, Mediawiki turns "syntaxhighlight" into an outer "div" and "pre", so adding another "pre" would be weird. -- Beland (talk) 17:12, 5 December 2024 (UTC)[reply]
Ah, looks like I forgot to save some of my changes. I'm looking at the example that uses "bar1=midnightblue". After I removed the spurious divs and set the font size back to 100%, the code in the left column is wrapping awkwardly. Setting "white-space: pre;" on the "pre" tag also works. I guess this is actually the one created by syntaxhighlight? I think adding something this to the right .css file should do that:
.mw-lang-highlight-wikitext pre {
  white-space: pre;
}
Though I would add a class to the {{clade example}} table so that change is more narrowly scoped and doesn't interfere with other "pre" elements elsewhere on the site. -- Beland (talk) 18:42, 5 December 2024 (UTC)[reply]
For clarification, with {{clade example}} the pre tag was only used when |codeN= contained the clade code wrapped in nowiki tags. This avoided duplication and allowed the clade code be reused, wrapped in the pre tag to display the code, and rendered to display the cladogram. In the documentation, only example 5 used this method. All the other examples displayed the code and output as given in the respective |codeN= and |outputN= parameters, using pre or syntaxhighlight as supplied to the parameters.
I've changed the reuse option (i.e. |codeN=<nowiki> code </nowiki>) to display the code with syntaxhighlight instead of pre.  —  Jts1882 | talk  08:10, 6 December 2024 (UTC)[reply]
I should add that none of the examples used in Template:Clade/doc use this nowiki method for reusing the code, so the module is not wrapping any of the code examples with pre or syntaxhighlight.
@Beland: I also edited the midnight blue example to avoid squeezing the output column. I've since noticed that this effectively reverted one of your edits. I think it looks better with the padding.  —  Jts1882 | talk  08:37, 6 December 2024 (UTC)[reply]