-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from natetrux/tree_styles_updates
Copying old docs over
- Loading branch information
Showing
9 changed files
with
1,901 additions
and
5 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Saving Figures\n", | ||
"Toytree drawings can be saved to disk using the `render` functions of toyplot. This is where it is useful to store the Canvas object as a variable when it is returned during a toytree drawing. You can save toyplot figures in a variety of formats, including HTML (which is actually an SVG figures wrapped in HTML with addition javascript to provide interactivity); or SVG, PDF, and PNG. " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<div class=\"toyplot\" id=\"ta14f8b33fb04430b8f132919754083c3\" style=\"text-align:center\"><svg class=\"toyplot-canvas-Canvas\" xmlns:toyplot=\"http://www.sandia.gov/toyplot\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns=\"http://www.w3.org/2000/svg\" width=\"400.0px\" height=\"300.0px\" viewBox=\"0 0 400.0 300.0\" preserveAspectRatio=\"xMidYMid meet\" style=\"background-color:transparent;border-color:#292724;border-style:none;border-width:1.0;fill:rgb(16.1%,15.3%,14.1%);fill-opacity:1.0;font-family:Helvetica;font-size:12px;opacity:1.0;stroke:rgb(16.1%,15.3%,14.1%);stroke-opacity:1.0;stroke-width:1.0\" id=\"t3e4fed78066f4a6d926cf06d77f941ca\"><g class=\"toyplot-coordinates-Cartesian\" id=\"tf73febdfa7fa453ab7a9091bbe97b346\"><clipPath id=\"t983485b582db40f783bcb44523b48047\"><rect x=\"35.0\" y=\"35.0\" width=\"330.0\" height=\"230.0\"></rect></clipPath><g clip-path=\"url(#t983485b582db40f783bcb44523b48047)\"><g class=\"toytree-mark-Toytree\" id=\"t5e09e7fd06a24b508eb808c0d3affa44\"><g class=\"toytree-Edges\" style=\"stroke:rgb(14.5%,14.5%,14.5%);stroke-opacity:1.0;stroke-linecap:round;stroke-width:2.0;fill:none\"><path d=\"M 114.7 223.3 L 114.7 243.3 L 306.3 243.3\" id=\"9,0\" style=\"\"></path><path d=\"M 178.6 203.3 L 178.6 216.6 L 306.3 216.6\" id=\"8,1\" style=\"\"></path><path d=\"M 178.6 203.3 L 178.6 190.0 L 306.3 190.0\" id=\"8,2\" style=\"\"></path><path d=\"M 242.4 150.0 L 242.4 163.3 L 306.3 163.3\" id=\"10,3\" style=\"\"></path><path d=\"M 242.4 150.0 L 242.4 136.7 L 306.3 136.7\" id=\"10,4\" style=\"\"></path><path d=\"M 178.6 130.0 L 178.6 110.0 L 306.3 110.0\" id=\"11,5\" style=\"\"></path><path d=\"M 178.6 70.0 L 178.6 83.4 L 306.3 83.4\" id=\"12,6\" style=\"\"></path><path d=\"M 178.6 70.0 L 178.6 56.7 L 306.3 56.7\" id=\"12,7\" style=\"\"></path><path d=\"M 114.7 223.3 L 114.7 203.3 L 178.6 203.3\" id=\"9,8\" style=\"\"></path><path d=\"M 50.9 161.7 L 50.9 223.3 L 114.7 223.3\" id=\"14,9\" style=\"\"></path><path d=\"M 178.6 130.0 L 178.6 150.0 L 242.4 150.0\" id=\"11,10\" style=\"\"></path><path d=\"M 114.7 100.0 L 114.7 130.0 L 178.6 130.0\" id=\"13,11\" style=\"\"></path><path d=\"M 114.7 100.0 L 114.7 70.0 L 178.6 70.0\" id=\"13,12\" style=\"\"></path><path d=\"M 50.9 161.7 L 50.9 100.0 L 114.7 100.0\" id=\"14,13\" style=\"\"></path></g><g class=\"toytree-AdmixEdges\" style=\"fill:rgb(0.0%,0.0%,0.0%);fill-opacity:0.0;stroke:rgb(90.6%,54.1%,76.5%);stroke-opacity:0.6;font-size:14px;stroke-linecap:round;stroke-width:5\"></g><g class=\"toytree-Nodes\" style=\"fill:rgb(40.0%,76.1%,64.7%);fill-opacity:1.0;stroke:rgb(14.9%,14.9%,14.9%);stroke-opacity:1.0;stroke-width:1.5\"></g><g class=\"toytree-TipLabels\" style=\"fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0;font-family:Helvetica;font-size:12px;font-weight:300;vertical-align:baseline;white-space:pre;stroke:none\"><g class=\"toytree-TipLabel\" transform=\"translate(306.289,243.284)\"><text x=\"15.0\" y=\"3.066\" style=\"fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0\">r0</text></g><g class=\"toytree-TipLabel\" transform=\"translate(306.289,216.631)\"><text x=\"15.0\" y=\"3.066\" style=\"fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0\">r1</text></g><g class=\"toytree-TipLabel\" transform=\"translate(306.289,189.979)\"><text x=\"15.0\" y=\"3.066\" style=\"fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0\">r2</text></g><g class=\"toytree-TipLabel\" transform=\"translate(306.289,163.326)\"><text x=\"15.0\" y=\"3.066\" style=\"fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0\">r3</text></g><g class=\"toytree-TipLabel\" transform=\"translate(306.289,136.674)\"><text x=\"15.0\" y=\"3.066\" style=\"fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0\">r4</text></g><g class=\"toytree-TipLabel\" transform=\"translate(306.289,110.021)\"><text x=\"15.0\" y=\"3.066\" style=\"fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0\">r5</text></g><g class=\"toytree-TipLabel\" transform=\"translate(306.289,83.3689)\"><text x=\"15.0\" y=\"3.066\" style=\"fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0\">r6</text></g><g class=\"toytree-TipLabel\" transform=\"translate(306.289,56.7164)\"><text x=\"15.0\" y=\"3.066\" style=\"fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0\">r7</text></g></g></g></g></g></svg><div class=\"toyplot-behavior\"><script>(function()\n", | ||
"{\n", | ||
"var modules={};\n", | ||
"})();</script></div></div>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"import toytree\n", | ||
"import toyplot\n", | ||
"\n", | ||
"rtre = toytree.rtree.unittree(ntips = 8)\n", | ||
"\n", | ||
"# draw a plot and store the Canvas object to a variable\n", | ||
"canvas, axes, mark = rtre.draw(width=400, height=300);" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"HTML rendering is the default format. This will save the figure as a vector graphic (SVG) wrapped in HTML with additional optional javascript wrapping for interactive features. You can share the file with others and anyone can open it in a browser. You can embed it on your website, or even display it in emails!" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 13, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"'c:\\\\Users\\\\natet\\\\Desktop\\\\eatonlab\\\\toytree_NT\\\\docs'" | ||
] | ||
}, | ||
"execution_count": 13, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"import os\n", | ||
"os.getcwd()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 14, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# for sharing through web-links (or even email!) html is great!\n", | ||
"toyplot.html.render(canvas, \"tmp/tree-plot.html\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Optional formats: If you want to do additional styling of your figures in Illustrator or InkScape (recommended) then SVG is likely your best option. You can save figures in SVG by simply importing this as an additional option from toyplot. " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 15, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# for creating scientific figures SVG is often the most useful format\n", | ||
"import toyplot.svg\n", | ||
"toyplot.svg.render(canvas, \"tmp/tree-plot.svg\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Despite the advantages of working with the SVG or HTML formats (e.g., vector graphics and interactive pop-ups), if you're like me you still sometimes love to have an old-fashioned PDF. Again, you can import this from toyplot. " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 16, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import toyplot.pdf\n", | ||
"toyplot.pdf.render(canvas, \"tmp/tree-plot.pdf\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Finally, PNG provides the most concise format for storing plots with many many many points in them, since it is a raster format, but has significant loss compared to the other formats above." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 17, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import toyplot.png\n", | ||
"toyplot.png.render(canvas, \"tmp/tree-plot.png\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "toytree_practice", | ||
"language": "python", | ||
"name": "toytree_practice" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="toyplot" id="t27c3bbeb24544d87a89af8b9df2964dd"><svg class="toyplot-canvas-Canvas" xmlns:toyplot="http://www.sandia.gov/toyplot" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" width="400.0px" height="300.0px" viewBox="0 0 400.0 300.0" preserveAspectRatio="xMidYMid meet" style="background-color:transparent;border-color:#292724;border-style:none;border-width:1.0;fill:rgb(16.1%,15.3%,14.1%);fill-opacity:1.0;font-family:Helvetica;font-size:12px;opacity:1.0;stroke:rgb(16.1%,15.3%,14.1%);stroke-opacity:1.0;stroke-width:1.0" id="t86005888a71e4415be35d32a5583c33f"><g class="toyplot-coordinates-Cartesian" id="t4b9bd58c6d2b4e53879c7b6a3b9ee2ad"><clipPath id="t3c557945a4114b8489e55fbeb16427d2"><rect x="35.0" y="35.0" width="330.0" height="230.0"></rect></clipPath><g clip-path="url(#t3c557945a4114b8489e55fbeb16427d2)"><g class="toytree-mark-Toytree" id="t2fce361ce76443668bf1b4405d219c83"><g class="toytree-Edges" style="stroke:rgb(14.5%,14.5%,14.5%);stroke-opacity:1.0;stroke-linecap:round;stroke-width:2.0;fill:none"><path d="M 114.7 223.3 L 114.7 243.3 L 306.3 243.3" id="9,0" style=""></path><path d="M 178.6 203.3 L 178.6 216.6 L 306.3 216.6" id="8,1" style=""></path><path d="M 178.6 203.3 L 178.6 190.0 L 306.3 190.0" id="8,2" style=""></path><path d="M 242.4 150.0 L 242.4 163.3 L 306.3 163.3" id="10,3" style=""></path><path d="M 242.4 150.0 L 242.4 136.7 L 306.3 136.7" id="10,4" style=""></path><path d="M 178.6 130.0 L 178.6 110.0 L 306.3 110.0" id="11,5" style=""></path><path d="M 178.6 70.0 L 178.6 83.4 L 306.3 83.4" id="12,6" style=""></path><path d="M 178.6 70.0 L 178.6 56.7 L 306.3 56.7" id="12,7" style=""></path><path d="M 114.7 223.3 L 114.7 203.3 L 178.6 203.3" id="9,8" style=""></path><path d="M 50.9 161.7 L 50.9 223.3 L 114.7 223.3" id="14,9" style=""></path><path d="M 178.6 130.0 L 178.6 150.0 L 242.4 150.0" id="11,10" style=""></path><path d="M 114.7 100.0 L 114.7 130.0 L 178.6 130.0" id="13,11" style=""></path><path d="M 114.7 100.0 L 114.7 70.0 L 178.6 70.0" id="13,12" style=""></path><path d="M 50.9 161.7 L 50.9 100.0 L 114.7 100.0" id="14,13" style=""></path></g><g class="toytree-AdmixEdges" style="fill:rgb(0.0%,0.0%,0.0%);fill-opacity:0.0;stroke:rgb(90.6%,54.1%,76.5%);stroke-opacity:0.6;font-size:14px;stroke-linecap:round;stroke-width:5"></g><g class="toytree-Nodes" style="fill:rgb(40.0%,76.1%,64.7%);fill-opacity:1.0;stroke:rgb(14.9%,14.9%,14.9%);stroke-opacity:1.0;stroke-width:1.5"></g><g class="toytree-TipLabels" style="fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0;font-family:Helvetica;font-size:12px;font-weight:300;vertical-align:baseline;white-space:pre;stroke:none"><g class="toytree-TipLabel" transform="translate(306.289,243.284)"><text x="15.0" y="3.066" style="fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0">r0</text></g><g class="toytree-TipLabel" transform="translate(306.289,216.631)"><text x="15.0" y="3.066" style="fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0">r1</text></g><g class="toytree-TipLabel" transform="translate(306.289,189.979)"><text x="15.0" y="3.066" style="fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0">r2</text></g><g class="toytree-TipLabel" transform="translate(306.289,163.326)"><text x="15.0" y="3.066" style="fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0">r3</text></g><g class="toytree-TipLabel" transform="translate(306.289,136.674)"><text x="15.0" y="3.066" style="fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0">r4</text></g><g class="toytree-TipLabel" transform="translate(306.289,110.021)"><text x="15.0" y="3.066" style="fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0">r5</text></g><g class="toytree-TipLabel" transform="translate(306.289,83.3689)"><text x="15.0" y="3.066" style="fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0">r6</text></g><g class="toytree-TipLabel" transform="translate(306.289,56.7164)"><text x="15.0" y="3.066" style="fill:rgb(14.5%,14.5%,14.5%);fill-opacity:1.0">r7</text></g></g></g></g></g></svg><div class="toyplot-behavior"><script>(function() | ||
{ | ||
var modules={}; | ||
})();</script></div></div> |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.