This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
272 additions
and
174 deletions.
There are no files selected for viewing
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
225 changes: 122 additions & 103 deletions
225
_unittests/ut_helpgen/notebooks_svg/notebook_with_svg.ipynb
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 |
---|---|---|
@@ -1,109 +1,128 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Notebook with SVG" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Notebook with SVG and javascript\n", | ||
"\n", | ||
"SVG in a notebook." | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"image/svg+xml": [ | ||
"<svg height=\"391\" viewBox=\"-70.5 -70.5 391 391\" width=\"391\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", | ||
"<defs>\n", | ||
"\t<pattern height=\"50\" id=\"grid\" patternUnits=\"userSpaceOnUse\" width=\"50\">\n", | ||
"\t\t<rect fill=\"#000\" height=\"1\" opacity=\"1.0\" width=\"50\" x=\"0\" y=\"0\"/>\n", | ||
"\t\t<rect fill=\"#000\" height=\"50\" opacity=\"1.0\" width=\"1\" x=\"0\" y=\"0\"/>\n", | ||
"\t</pattern>\n", | ||
"\t<pattern height=\"50\" id=\"dots\" patternUnits=\"userSpaceOnUse\" width=\"50\">\n", | ||
"\t\t<g fill-opacity=\"0.40\" stroke=\"#000\" stroke-dasharray=\"0.3,0.3\">\n", | ||
"\t\t\t<circle cx=\"0\" cy=\"0\" fill=\"red\" r=\"4\"/>\n", | ||
"\t\t\t<circle cx=\"51\" cy=\"0\" fill=\"blue\" r=\"4\"/>\n", | ||
"\t\t\t<circle cx=\"51\" cy=\"51\" fill=\"green\" r=\"4\"/>\n", | ||
"\t\t\t<circle cx=\"0\" cy=\"51\" fill=\"yellow\" r=\"4\"/>\n", | ||
"\t\t</g>\n", | ||
"\t</pattern>\n", | ||
"</defs>\n", | ||
"<rect fill=\"#fff\" height=\"390\" stroke=\"#000\" width=\"390\" x=\"-70\" y=\"-70\"/>\n", | ||
"<rect fill=\"url(#dots)\" height=\"250\" width=\"250\" x=\"0\" y=\"0\"/>\n", | ||
"<rect fill=\"url(#grid)\" height=\"250\" stroke=\"#000\" stroke-width=\"2\" width=\"250\" x=\"0\" y=\"0\"/>\n", | ||
"<text font-family=\"Times New Roman,serif\" font-size=\"16\" text-anchor=\"middle\" x=\"0\" y=\"0\">\n", | ||
"<tspan font-weight=\"bold\" x=\"125\" y=\"-40\">X</tspan>\n", | ||
"<tspan x=\"0\" y=\"-10\">0</tspan>\n", | ||
"<tspan x=\"50\" y=\"-10\">50</tspan>\n", | ||
"<tspan x=\"100\" y=\"-10\">100</tspan>\n", | ||
"<tspan x=\"150\" y=\"-10\">150</tspan>\n", | ||
"<tspan x=\"200\" y=\"-10\">200</tspan>\n", | ||
"<tspan x=\"250\" y=\"-10\">250</tspan>\n", | ||
"</text>\n", | ||
"<text font-family=\"Times New Roman,serif\" font-size=\"16\" text-anchor=\"middle\" x=\"0\" y=\"0\">\n", | ||
"<tspan font-weight=\"bold\" x=\"-50\" y=\"125\">Y</tspan>\n", | ||
"<tspan dy=\"6\" x=\"-20\" y=\"0\">0</tspan>\n", | ||
"<tspan dy=\"6\" x=\"-20\" y=\"50\">50</tspan>\n", | ||
"<tspan dy=\"6\" x=\"-20\" y=\"100\">100</tspan>\n", | ||
"<tspan dy=\"6\" x=\"-20\" y=\"150\">150</tspan>\n", | ||
"<tspan dy=\"6\" x=\"-20\" y=\"200\">200</tspan>\n", | ||
"<tspan dy=\"6\" x=\"-20\" y=\"250\">250</tspan>\n", | ||
"</text>\n", | ||
"<g opacity=\"0.8\">\n", | ||
"\t<rect fill=\"lime\" height=\"200\" stroke=\"pink\" stroke-width=\"4\" width=\"200\" x=\"25\" y=\"25\"/>\n", | ||
"\t<circle cx=\"125\" cy=\"125\" fill=\"orange\" r=\"75\"/>\n", | ||
"\t<polyline fill=\"none\" points=\"50,150 50,200 200,200 200,100\" stroke=\"red\" stroke-width=\"4\"/>\n", | ||
"\t<line stroke=\"blue\" stroke-width=\"4\" x1=\"50\" x2=\"200\" y1=\"50\" y2=\"200\"/>\n", | ||
"</g>\n", | ||
"</svg>" | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"image/svg+xml": [ | ||
"<svg height=\"391\" viewBox=\"-70.5 -70.5 391 391\" width=\"391\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", | ||
"<defs>\n", | ||
"\t<pattern height=\"50\" id=\"grid\" patternUnits=\"userSpaceOnUse\" width=\"50\">\n", | ||
"\t\t<rect fill=\"#000\" height=\"1\" opacity=\"1.0\" width=\"50\" x=\"0\" y=\"0\"/>\n", | ||
"\t\t<rect fill=\"#000\" height=\"50\" opacity=\"1.0\" width=\"1\" x=\"0\" y=\"0\"/>\n", | ||
"\t</pattern>\n", | ||
"</defs>\n", | ||
"<rect fill=\"#fff\" height=\"390\" stroke=\"#000\" width=\"390\" x=\"-70\" y=\"-70\"/>\n", | ||
"<rect fill=\"url(#grid)\" height=\"250\" stroke=\"#000\" stroke-width=\"2\" width=\"250\" x=\"0\" y=\"0\"/>\n", | ||
"<text font-family=\"Granada,Times New Roman,serif\" font-size=\"16\" text-anchor=\"middle\" x=\"0\" y=\"0\">\n", | ||
"<tspan font-size=\"1.2em\" font-weight=\"bold\" x=\"125\" y=\"-40\">x</tspan>\n", | ||
"<tspan x=\"0\" y=\"-10\">0</tspan>\n", | ||
"<tspan x=\"50\" y=\"-10\">50</tspan>\n", | ||
"<tspan x=\"100\" y=\"-10\">100</tspan>\n", | ||
"<tspan x=\"150\" y=\"-10\">150</tspan>\n", | ||
"<tspan x=\"200\" y=\"-10\">200</tspan>\n", | ||
"<tspan x=\"250\" y=\"-10\">250</tspan>\n", | ||
"</text>\n", | ||
"<text font-family=\"Granada,Times New Roman,serif\" font-size=\"16\" text-anchor=\"middle\" x=\"0\" y=\"0\">\n", | ||
"<tspan font-size=\"1.2em\" font-weight=\"bold\" x=\"-50\" y=\"125\">y</tspan>\n", | ||
"<tspan dy=\"6\" x=\"-20\" y=\"0\">0</tspan>\n", | ||
"<tspan dy=\"6\" x=\"-20\" y=\"50\">50</tspan>\n", | ||
"<tspan dy=\"6\" x=\"-20\" y=\"100\">100</tspan>\n", | ||
"<tspan dy=\"6\" x=\"-20\" y=\"150\">150</tspan>\n", | ||
"<tspan dy=\"6\" x=\"-20\" y=\"200\">200</tspan>\n", | ||
"<tspan dy=\"6\" x=\"-20\" y=\"250\">250</tspan>\n", | ||
"</text>\n", | ||
"<g opacity=\"0.8\">\n", | ||
"\t<rect fill=\"lime\" height=\"200\" stroke=\"pink\" stroke-width=\"4\" width=\"200\" x=\"25\" y=\"25\"/>\n", | ||
"\t<circle cx=\"125\" cy=\"125\" fill=\"orange\" r=\"75\"/>\n", | ||
"\t<polyline fill=\"none\" points=\"50,150 50,200 200,200 200,100\" stroke=\"red\" stroke-width=\"4\"/>\n", | ||
"\t<line stroke=\"blue\" stroke-width=\"4\" x1=\"50\" x2=\"200\" y1=\"50\" y2=\"200\"/>\n", | ||
"</g>\n", | ||
"</svg>" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.SVG object>" | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.SVG object>" | ||
"source": [ | ||
"from IPython.core.display import SVG\n", | ||
"SVG(url=\"https://upload.wikimedia.org/wikipedia/commons/1/1a/SVG_example_markup_grid.svg\")" | ||
] | ||
}, | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<div id=\"M929581e8070743239b9d45c37e5c08e8-cont\"><div id=\"M929581e8070743239b9d45c37e5c08e8\" style=\"width:100%;height:100%;\"></div></div>\n", | ||
"<script>\n", | ||
"\n", | ||
"require(['http://www.xavierdupre.fr/js/vizjs/viz.js'], function() { var svgGraph = Viz(\"digraph{ a-> b; a-> c -> d;}\");\n", | ||
"document.getElementById('M929581e8070743239b9d45c37e5c08e8').innerHTML = svgGraph; });\n", | ||
"\n", | ||
"</script>" | ||
], | ||
"text/plain": [ | ||
"<jyquickhelper.jspy.render_nb_js_dot.RenderJsDot at 0x2b475bb2da0>" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from jyquickhelper import RenderJsDot\n", | ||
"RenderJsDot('digraph{ a-> b; a-> c -> d;}')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.7.0" | ||
} | ||
], | ||
"source": [ | ||
"from IPython.core.display import SVG\n", | ||
"SVG(url=\"https://upload.wikimedia.org/wikipedia/commons/1/1a/SVG_example_markup_grid.svg\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.4.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} | ||
"nbformat": 4, | ||
"nbformat_minor": 1 | ||
} |
Oops, something went wrong.