This repository has been archived by the owner on Jul 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extending.html
7 lines (7 loc) · 8.69 KB
/
extending.html
1
2
3
4
5
6
7
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Extending · Makie.jl</title><link href="https://fonts.googleapis.com/css?family=Lato|Roboto+Mono" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="assets/documenter.js"></script><script src="siteinfo.js"></script><script src="../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-dark.css" data-theme-name="documenter-dark"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="assets/themeswap.js"></script><link href="assets/favicon.ico" rel="icon" type="image/x-icon"/><link href="assets/syntaxtheme.css" rel="stylesheet" type="text/css"/></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="index.html"><img src="assets/logo.png" alt="Makie.jl logo"/></a><div class="docs-package-name"><span class="docs-autofit">Makie.jl</span></div><form class="docs-search" action="search.html"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="index.html">Home</a></li><li><span class="tocitem">Basics</span><ul><li><a class="tocitem" href="basic-tutorial.html">Tutorial</a></li><li><a class="tocitem" href="animation.html">Animations</a></li><li><a class="tocitem" href="interaction.html">Interaction</a></li><li><a class="tocitem" href="plotting_functions.html">Plotting Functions</a></li></ul></li><li><span class="tocitem">Documentation</span><ul><li><a class="tocitem" href="scenes.html">Scenes</a></li><li><a class="tocitem" href="generated/axis.html">Axis</a></li><li><a class="tocitem" href="convenience.html">Convenience functions</a></li><li><a class="tocitem" href="generated/signatures.html">Plot function signatures</a></li><li><a class="tocitem" href="generated/plot-attributes.html">Plot attributes</a></li><li><a class="tocitem" href="generated/colors.html">Colors</a></li><li><a class="tocitem" href="lighting.html">Lighting</a></li><li><a class="tocitem" href="theming.html">Config file</a></li><li><a class="tocitem" href="cameras.html">Cameras</a></li><li><a class="tocitem" href="recipes.html">Plot Recipes</a></li><li><a class="tocitem" href="output.html">Output</a></li><li><a class="tocitem" href="backends.html">Backends</a></li><li><a class="tocitem" href="troubleshooting.html">Troubleshooting</a></li></ul></li><li><span class="tocitem">MakieLayout</span><ul><li><a class="tocitem" href="makielayout/tutorial.html">Tutorial</a></li><li><a class="tocitem" href="makielayout/grids.html">GridLayout</a></li><li><a class="tocitem" href="makielayout/laxis.html">LAxis</a></li><li><a class="tocitem" href="makielayout/special_plots.html">Special Plots</a></li><li><a class="tocitem" href="makielayout/llegend.html">LLegend</a></li><li><a class="tocitem" href="makielayout/layoutables_examples.html">Layoutables Examples</a></li><li><a class="tocitem" href="makielayout/theming.html">Theming Layoutables</a></li><li><a class="tocitem" href="makielayout/layouting.html">How Layouting Works</a></li><li><a class="tocitem" href="makielayout/faq.html">Frequently Asked Questions</a></li><li><a class="tocitem" href="makielayout/reference.html">API Reference</a></li></ul></li><li><span class="tocitem">Developer Documentation</span><ul><li><a class="tocitem" href="why-makie.html">Why <code>Makie</code>?</a></li><li><a class="tocitem" href="devdocs.html">Devdocs</a></li><li><a class="tocitem" href="abstractplotting_api.html">AbstractPlotting Reference</a></li></ul></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href="extending.html">Extending</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href="extending.html">Extending</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/JuliaPlots/AbstractPlotting.jl/blob/master/docs/src/extending.md#" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Extending"><a class="docs-heading-anchor" href="#Extending">Extending</a><a id="Extending-1"></a><a class="docs-heading-anchor-permalink" href="#Extending" title="Permalink"></a></h1><p>There are 3 ways to extend Makie:</p><ol><li>By creating a new function combining multiple plotting commands (duh)</li><li>By overloading conversions for your custom type</li><li>By overloading plot(...) for your own type</li></ol><h2 id="Option-1"><a class="docs-heading-anchor" href="#Option-1">Option 1</a><a id="Option-1-1"></a><a class="docs-heading-anchor-permalink" href="#Option-1" title="Permalink"></a></h2><p>The first option is quite trivial and can be done in any plotting package and language: just create a function that scripts together a Plot.</p><h2 id="Option-2"><a class="docs-heading-anchor" href="#Option-2">Option 2</a><a id="Option-2-1"></a><a class="docs-heading-anchor-permalink" href="#Option-2" title="Permalink"></a></h2><p>The plotting pipeline heavily relies on conversion functions which check the attributes for validity, document what's possible to pass and convert them to the types that the backends need. They usually look like this:</p><pre><code class="language-julia">to_positions(backend, positions) = Point3f0.(positions) # E.g. everything that can be converted to a Point</code></pre><p>As you can see, the first argument is the backend, so you can overload this for a specific backend or for a specific position type. This can look something like this:</p><p>@library[example] "overload to position"</p><p>since the pipeline for converting attributes also knows about Circle now, we can update the attribute directly with our own type</p><p>@library[example] "change size"</p><h2 id="Option-3"><a class="docs-heading-anchor" href="#Option-3">Option 3</a><a id="Option-3-1"></a><a class="docs-heading-anchor-permalink" href="#Option-3" title="Permalink"></a></h2><p>Option 3 is very similar to Plots.jl recipes. Inside the function you can just use all of the plotting and drawing API to create a rich visual representation of your type. The signature that needs overloading is:</p><pre><code class="language-julia">function plot(obj::MyType, kw_args::Dict)
# use primitives and other recipes to create a new plot
scatter(obj, kw_arg[:my_attribute])
lines(...)
polygon(...)
end</code></pre></article><nav class="docs-footer"><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> on <span class="colophon-date" title="Tuesday 20 October 2020 08:14">Tuesday 20 October 2020</span>. Using Julia version 1.3.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>