Template talk:Clade
This template does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||
|
This template was considered for merging with Template:Cladogram on 2018 April 24. The result of the discussion was "do not merge". |
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.
B. ser. Abietinae |
| ||||||||||||
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)
- 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
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)
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)
- 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)
- 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)
- 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)
- Works for me on Firefox 5 and IE 8, still looks awful in Chrome 12. Hesperian 11:48, 27 July 2011 (UTC)
- 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.
- Works for me on Firefox 5 and IE 8, still looks awful in Chrome 12. Hesperian 11:48, 27 July 2011 (UTC)
- 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)
- 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)
|
|
- 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)
- 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)
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)
other lines
[edit]Any possibility of dbl/triple lines for polyphyletic groups, or other common conventions? kwami (talk) 09:51, 25 November 2008 (UTC)
- It's now also easier to produce double lines by using {{Cladex}}. Peter coxhead (talk) 08:30, 27 July 2011 (UTC)
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)
Lemur phylogeny | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
Source: Horvath, et al. (2008)[1] |
|
References
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)
- 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)
- 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)
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)
Dashed lines?
[edit]Is there a way to add dashed lines for uncertain relationships? – VisionHolder « talk » 23:38, 20 May 2010 (UTC)
- Now there is: |stateN=dashed. Ucucha 20:38, 31 May 2010 (UTC)
Browser differences - Chrome vs. Firefox
[edit]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)
- 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)
- 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)
- 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)
- If the problem is with empty table cells, one could put say a   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)
- I think there are already nbsp's in these cells. Ucucha 20:33, 3 October 2010 (UTC)
- 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)
- 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)
- 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)
- 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)
- 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)
- I think there are already nbsp's in these cells. Ucucha 20:33, 3 October 2010 (UTC)
- If the problem is with empty table cells, one could put say a   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)
- 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)
- 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)
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)
- 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)
- 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 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)
- 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)
- 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 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)
- 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)
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)
- 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.
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
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)
- It's now easier to do this via {{Cladex}}; see its documentation. Peter coxhead (talk) 09:25, 27 July 2011 (UTC)
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)
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)
- 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.
|
|
|
- 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)
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)
- Try using the no-break space (
) 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)
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>|" "|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 (talk • contribs) 20:27, 31 May 2011 (UTC)
- Updated. Bob the WikipediaN (talk • contribs) 21:15, 31 May 2011 (UTC)
- 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)
- 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 (talk • contribs) 01:13, 1 June 2011 (UTC)- 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)
- 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 (talk • contribs) 16:51, 1 June 2011 (UTC)
- 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)
- 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)
- Perhaps
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)
- 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)
- 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)
- 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)
- 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 (talk • contribs) 21:02, 7 June 2011 (UTC)
- 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)
- 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:
- 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 (talk • contribs) 21:02, 7 June 2011 (UTC)
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)
- I'd go with "cladogram". Petter Bøckman (talk) 06:55, 8 June 2011 (UTC)
- 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 (talk • contribs) 14:28, 8 June 2011 (UTC)
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)
- 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)
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)
- Tests of IE6 were carried out and it seemed to be ok. Peter coxhead (talk) 09:26, 27 July 2011 (UTC)
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)
- 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)
- 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)
Ah, OK. Thanks, Peter. --Stemonitis (talk) 06:06, 23 July 2011 (UTC)
- 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)
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 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)
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)
- 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:
| |||||||||||||
| |||||||||||||
- (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)
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)
- 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)
- 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)
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)
- I have to say it could look quite nice if the right images are used. Shyamal (talk) 10:11, 21 August 2015 (UTC)
- 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)
- 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:
- 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)
- 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)
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 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
- 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)
- 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)
- @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)
- Ok. Thanks.Bookworm8899 (talk) 05:30, 9 September 2015 (UTC)
- @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)
- 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)
- 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)
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|†]]}}
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)
- The template {{extinct}} is often used to create the dagger character. Peter coxhead (talk) 19:11, 4 June 2016 (UTC)
- 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)
- 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)
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)
- @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)
- 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)
- 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)
- 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)
- @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)
- 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)
- @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 justa
; students who wroteif a==true then
rather thanif 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)
- @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:
- @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)
- @Peter coxhead: Thanks for the feedback. Some answers to above points and questions.
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)
Node structure |
|
|label1=Node structure |sublabel1=(brackets)
|style1=background-color:#ffdddd;
|1={{Clade
|label1=label1
|1=leaf 1
|label2=label2
|grouplabel2= 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 |
|
|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= 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= #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= line styles
|4=none |state4=none |bar4=purple
|5=double |state5=double |barend5=purple
}}
}}
| |||||||||||||||||||||||||||||||||||||||||||||||
(branches) | |||||||||||||||||||||||||||||||||||||||||||||||||
node styling |
|
|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 |
|
|label6=newick
|style6=background-color:#ddffdd;
|6={{Clade
|label1=string
|1=((lion,jaguar,leopard),((siberian,bengal)tiger,snow leopard))panthera
|label2=subtree
|grouplabel2= 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 |
|
|label7=paraphyly example |style7=background-color:#ffeeff;
|7={{Clade
|1={{Clade
|1=[[Geraniales]]
|2=[[Myrtales]]
}}
|grouplabel2= 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)
- @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)
- 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)
- @Jts1882: \o/ awesome Shyamal (talk) 11:23, 12 December 2016 (UTC)
- 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)
- 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)
- @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)
- @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)
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)
- @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)
- @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)
- 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)
- 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)
- 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)
- @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)
- 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)
- 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)
- 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)
- 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)
- 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)
- Ok, progress.
- @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)
- 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)
- @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)
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)
- 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)
- The style inspector indicates "inherit" on
border:
will clobber border-style and border-width per the spec. If we useborder-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)
- The style inspector indicates "inherit" on
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)
- 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)
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)
Cactaceae |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Cactaceae |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- @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 |
- cladex rows:
- 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)
- 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)
- 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)
- 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)
- 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 |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- Very cumbersome, but an option that can be used without any changes to the template. Jts1882 (talk) 06:51, 28 March 2017 (UTC)
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.
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}} | |
Peter coxhead (talk) 19:49, 2 May 2017 (UTC)
- 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)
- 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)
- 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)
- @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)
- 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)
- Ok, we agree; now fixed in the live version. Peter coxhead (talk) 16:18, 3 May 2017 (UTC)
- 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)
- @Jts1882: several points:
"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)
- 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)
- Thanks for the tip - I'll check it out. Timtempleton (talk) 00:34, 14 June 2017 (UTC)
- @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)
- @Timtempleton: If you haven't seen it by now,
- Thanks for the tip - I'll check it out. Timtempleton (talk) 00:34, 14 June 2017 (UTC)
|
|
- @UtherSRG: - Thanks for the ping. Good to know. TimTempleton (talk) (cont) 13:45, 21 September 2022 (UTC)
Error messages
[edit]Physeteroidea | ||
|
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)
- @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)
- 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)
Template-protected edit request on 17 April 2018
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
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)
- Was already done. — xaosflux Talk 17:52, 17 April 2018 (UTC)
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 |
| |||||||||||||||
Any thoughts? Jts1882 | talk 09:19, 26 June 2018 (UTC)
- 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)
- 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)
- 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)
Amphibia |
| |||||||||
- 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)
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 |
| |||||||||
Amphibia |
| |||||||||
Amphibia |
| |||||||||
- |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)
- 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)- 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
|
- 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)
- @UtherSRG: The example now works crudely with the external toggle. — Jts1882 | talk 15:36, 21 September 2022 (UTC)
- 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)
- 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)
Oh... I see... A/B is one phylogeny, and Leaf1/2 is another phylogeny. Hrm..... - UtherSRG (talk) 15:46, 21 September 2022 (UTC)
Lemuroidea |
| |||
- @UtherSRG: Isn't the above a crude version of what you want? — Jts1882 | talk 16:02, 21 September 2022 (UTC)
- 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)
- I have the larger structure started in my sandbox. - UtherSRG (talk) 17:01, 21 September 2022 (UTC)
- 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)
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)
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)
- 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)- @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)
- 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)
- 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)
- 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)
- (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)
- 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)
- @Jts1882: Thank you! And also thank you for fixing the bean-tree! kupirijo (talk) 15:36, 27 March 2020 (UTC)
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)
- Done. I've also removed Craciformes as that hasn't been used for ages. — Jts1882 | talk 05:49, 30 August 2024 (UTC)
Whitespace around labels
[edit]I've noticed several clade diagrams have HTML entities like   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)
- 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)
- 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)
- 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)
- @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)- 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)
- 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)
- 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)
- 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)
- 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)
- 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)