def rotate_node(<EOL>self, <EOL>names=None, <EOL>wildcard=None, <EOL>regex=None, <EOL>idx=None, <EOL>):
<EOL>revd = {j: i for (i, j) in enumerate(self.get_tip_labels())}<EOL>neworder = {}<EOL>treenode = fuzzy_match_tipnames(<EOL>self, names, wildcard, regex, True, True)<EOL>children = treenode.up.children<EOL>names = [[j.name for j in i.get_leaves()] for i in children]<EOL>nidxs = [[revd[i] for i in j] for j in names]<EOL>move = max((len(i) for i in nidxs))<EOL>if len(nidxs[<NUM_LIT:0>]) > len(nidxs[<NUM_LIT:1>]):<EOL><INDENT>move = min((len(i) for i in nidxs))<EOL><DEDENT>cnames = list(itertools.chain(*names))<EOL>tdict = {i: None for i in cnames}<EOL>cycle = itertools.cycle(itertools.chain(*nidxs))<EOL>for m in range(move):<EOL><INDENT>next(cycle)<EOL><DEDENT>for t in cnames:<EOL><INDENT>tdict[t] = next(cycle)<EOL><DEDENT>for key in revd:<EOL><INDENT>if key in tdict:<EOL><INDENT>neworder[key] = tdict[key]<EOL><DEDENT>else:<EOL><INDENT>neworder[key] = revd[key]<EOL><DEDENT><DEDENT>revd = {j: i for (i, j) in neworder.items()}<EOL>neworder = [revd[i] for i in range(self.ntips)]<EOL>nself = ToyTree(self.newick, fixed_order=neworder)<EOL>nself._coords.update()<EOL>return nself<EOL>
Returns a ToyTree with the selected node rotated for plotting.
tip colors do not align correct currently if nodes are rotated...