{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# TikzGraphs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This library uses the LaTeX package [pgf/tikz](http://www.ctan.org/pkg/pgf) to produce graphs. It integrates with IJulia, outputting SVG images to the notebook." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Installation" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "using Pkg\n", "Pkg.add(\"TikzGraphs\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In addition, you will need to install the following dependencies if you do not already have them on your system.\n", "* Pdf2svg. This is required by TikzPictures. On Ubuntu, you can get this by running `sudo apt-get install pdf2svg`. On Windows, you can download the binaries from http://www.cityinthesky.co.uk/opensource/pdf2svg/. Be sure to add pdf2svg to your path (and restart).\n", "* Pgf (version 3.0 or later). Install using your latex package manager (e.g., texlive or miktex).\n", "\n", "Once these things are installed, you should be able to run the following:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "using TikzGraphs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Examples" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPictures.TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"1\\\" [],\\n2/\\\"2\\\" [],\\n3/\\\"3\\\" [],\\n4/\\\"4\\\" [],\\n;\\n1 -> [,] 2;\\n2 -> [,] 3;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "using TikzGraphs\n", "using Graphs\n", "g = DiGraph(4)\n", "add_edge!(g, 1, 2)\n", "add_edge!(g, 2, 3)\n", "TikzGraphs.plot(g)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPictures.TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"1\\\" [],\\n2/\\\"2\\\" [],\\n3/\\\"3\\\" [],\\n4/\\\"4\\\" [],\\n;\\n1 -> [,] 2;\\n1 -> [,] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "add_edge!(g, 3, 4)\n", "add_edge!(g, 1, 4)\n", "TikzGraphs.plot(g)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can save your graphs to PDF, SVG, and TEX." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "t = TikzGraphs.plot(g)\n", "using TikzPictures # this is required for saving\n", "TikzPictures.save(PDF(\"graph\"), t)\n", "TikzPictures.save(SVG(\"graph\"), t)\n", "TikzPictures.save(TEX(\"graph\"), t)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Labels" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can also specify the node labels." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"A\\\" [],\\n2/\\\"B\\\" [],\\n3/\\\"C\\\" [],\\n4/\\\"D\\\" [],\\n;\\n1 -> [,] 2;\\n1 -> [,] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, [\"A\", \"B\", \"C\", \"D\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can even use unicode." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"α\\\" [],\\n2/\\\"β\\\" [],\\n3/\\\"γ\\\" [],\\n4/\\\"δ\\\" [],\\n;\\n1 -> [,] 2;\\n1 -> [,] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, [\"α\", \"β\", \"γ\", \"δ\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can also have latex labels." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"\\$\\\\int_0^\\\\infty f(x) dx\\$\\\" [],\\n2/\\\"\\$\\\\sqrt{2}\\$\\\" [],\\n3/\\\"\\$x^2\\$\\\" [],\\n4/\\\"\\$\\\\frac{1}{2}\\$\\\" [],\\n;\\n1 -> [,] 2;\\n1 -> [,] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "using LaTeXStrings\n", "TikzGraphs.plot(g, [L\"\\int_0^\\infty f(x) dx\", L\"\\sqrt{2}\", L\"x^2\", L\"\\frac{1}{2}\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can have repeated labels." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"α\\\" [],\\n2/\\\"β\\\" [],\\n3/\\\"γ\\\" [],\\n4/\\\"α\\\" [],\\n;\\n1 -> [,] 2;\\n1 -> [,] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, [\"α\", \"β\", \"γ\", \"α\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can specify the style for the nodes." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"α\\\" [draw, rounded corners, fill=blue!10],\\n2/\\\"β\\\" [draw, rounded corners, fill=blue!10],\\n3/\\\"γ\\\" [draw, rounded corners, fill=blue!10],\\n4/\\\"α\\\" [draw, rounded corners, fill=blue!10],\\n;\\n1 -> [,] 2;\\n1 -> [,] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, [\"α\", \"β\", \"γ\", \"α\"], node_style=\"draw, rounded corners, fill=blue!10\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can override the styles of selected nodes using a dictionary." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"α\\\" [draw, rounded corners, fill=blue!10,fill=green!10],\\n2/\\\"β\\\" [draw, rounded corners, fill=blue!10],\\n3/\\\"γ\\\" [draw, rounded corners, fill=blue!10,fill=yellow!10],\\n4/\\\"α\\\" [draw, rounded corners, fill=blue!10],\\n;\\n1 -> [,] 2;\\n1 -> [,] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, [\"α\", \"β\", \"γ\", \"α\"], node_style=\"draw, rounded corners, fill=blue!10\", node_styles=Dict(1=>\"fill=green!10\",3=>\"fill=yellow!10\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Edges" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can set edge labels using a dictionary." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"α\\\" [],\\n2/\\\"β\\\" [],\\n3/\\\"γ\\\" [],\\n4/\\\"α\\\" [],\\n;\\n1 -> [,edge label={x},] 2;\\n1 -> [,edge label={y},] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, [\"α\", \"β\", \"γ\", \"α\"], edge_labels=Dict((1,2)=>\"x\", (1,4)=>\"y\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can set the style for the edges." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"α\\\" [],\\n2/\\\"β\\\" [],\\n3/\\\"γ\\\" [],\\n4/\\\"α\\\" [],\\n;\\n1 -> [green,edge label={x},] 2;\\n1 -> [green,edge label={y},] 4;\\n2 -> [green,] 3;\\n3 -> [green,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, [\"α\", \"β\", \"γ\", \"α\"], edge_labels=Dict((1,2)=>\"x\", (1,4)=>\"y\"), edge_style=\"green\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can overide the style for specific edges as specified by a dictionary." ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"1\\\" [],\\n2/\\\"2\\\" [],\\n3/\\\"3\\\" [],\\n4/\\\"4\\\" [],\\n;\\n1 -> [green,edge label={x},blue,] 2;\\n1 -> [green,edge label={y},] 4;\\n2 -> [green,] 3;\\n3 -> [green,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, edge_labels=Dict((1,2)=>\"x\", (1,4)=>\"y\"), edge_style=\"green\", edge_styles=Dict((1,2)=>\"blue\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can draw self-loop edges by specifying the edge style." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"1\\\" [],\\n2/\\\"2\\\" [],\\n3/\\\"3\\\" [],\\n4/\\\"4\\\" [],\\n;\\n1 -> [,edge label={x},] 2;\\n1 -> [,edge label={y},] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n4 -> [,edge label={loop},loop right,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "loop_g = deepcopy(g)\n", "add_edge!(loop_g, (4,4))\n", "TikzGraphs.plot(loop_g, edge_labels=Dict((1,2)=>\"x\", (1,4)=>\"y\", (4,4)=>\"loop\"), edge_styles=Dict((4,4)=>\"loop right\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Layouts" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can use different layouts (currently just Layered [default], Spring, and SimpleNecklace are supported)." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"1\\\" [],\\n2/\\\"2\\\" [],\\n3/\\\"3\\\" [],\\n4/\\\"4\\\" [],\\n;\\n1 -> [,] 2;\\n1 -> [,] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, Layouts.Layered())" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [spring layout, random seed = 42,] {\\n1/\\\"1\\\" [],\\n2/\\\"2\\\" [],\\n3/\\\"3\\\" [],\\n4/\\\"4\\\" [],\\n;\\n1 -> [,] 2;\\n1 -> [,] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{force}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, Layouts.Spring())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can set the random seed for the Spring layout." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [spring layout, random seed = 52,] {\\n1/\\\"1\\\" [],\\n2/\\\"2\\\" [],\\n3/\\\"3\\\" [],\\n4/\\\"4\\\" [],\\n;\\n1 -> [,] 2;\\n1 -> [,] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{force}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, Layouts.Spring(randomSeed=52))" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [simple necklace layout, ] {\\n1/\\\"1\\\" [],\\n2/\\\"2\\\" [],\\n3/\\\"3\\\" [],\\n4/\\\"4\\\" [],\\n;\\n1 -> [,] 2;\\n1 -> [,] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{circular}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, Layouts.SimpleNecklace())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Options" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", "\n" ], "text/plain": [ "TikzPicture(\"\\\\graph [layered layout, ] {\\n1/\\\"1\\\" [draw],\\n2/\\\"2\\\" [draw],\\n3/\\\"3\\\" [draw],\\n4/\\\"4\\\" [draw],\\n;\\n1 -> [,] 2;\\n1 -> [,] 4;\\n2 -> [,] 3;\\n3 -> [,] 4;\\n};\\n\", \"scale=2, font=\\\\huge\\\\sf\", \"\\\\usepackage{fontspec}\\n\\\\setmainfont{Latin Modern Math}\\n\\\\usetikzlibrary{arrows}\\n\\\\usetikzlibrary{graphs}\\n\\\\usetikzlibrary{graphdrawing}\\n\\n% from: https://tex.stackexchange.com/questions/453132/fresh-install-of-tl2018-no-tikz-graph-drawing-libraries-found\\n\\\\usepackage{luacode}\\n\\\\begin{luacode*}\\n\\tfunction pgf_lookup_and_require(name)\\n\\tlocal sep = package.config:sub(1,1)\\n\\tlocal function lookup(name)\\n\\tlocal sub = name:gsub('%.',sep) \\n\\tif kpse.find_file(sub, 'lua') then\\n\\trequire(name)\\n\\telseif kpse.find_file(sub, 'clua') then\\n\\tcollectgarbage('stop') \\n\\trequire(name)\\n\\tcollectgarbage('restart')\\n\\telse\\n\\treturn false\\n\\tend\\n\\treturn true\\n\\tend\\n\\treturn\\n\\tlookup('pgf.gd.' .. name .. '.library') or\\n\\tlookup('pgf.gd.' .. name) or\\n\\tlookup(name .. '.library') or\\n\\tlookup(name) \\n\\tend\\n\\\\end{luacode*}\\n\\n\\\\usegdlibrary{layered}\", \"tikzpicture\", \"\", \"\", true, true)" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "TikzGraphs.plot(g, node_style=\"draw\", options=\"scale=2, font=\\\\huge\\\\sf\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Future Plans" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Gradually, more functionality from pgf/tikz will be migrated into this package." ] } ], "metadata": { "@webio": { "lastCommId": null, "lastKernelId": null }, "kernelspec": { "display_name": "Julia 1.6.0", "language": "julia", "name": "julia-1.6" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.6.0" } }, "nbformat": 4, "nbformat_minor": 1 }