PlutoVista.jl
Plot library for Pluto notebooks based on plotly.js for 1D data and vtk.js (thus using WebGL) for 2/3D data.
It uses the Pluto 💁 API to make objects available inside JS to pass plot data from Julia to HTML5.
Please see:
So far, this package is in an early state.
PlutoVistaPlot
PlutoVista.PlutoVistaPlot — Typemutable struct PlutoVistaPlotPlutoVistaPlot is a wrapper struct around different possible backends. As default, for 1D plots, PlutoPlotlyPlot and for 2D and 3D plots, PlutoVTKPlot are chosen. The backend is automatically chosen when the first plot is invoked.
PlutoVista.PlutoVistaPlot — MethodPlutoVistaPlot(; resolution, kwargs...)
Constructor for PlutoVistaPlot.
Relevant keyword arguments:
- resolution: Screen resolution in pixels
- dim: Space dimension of subsequent plots
1D plots
PlutoVista.plot — Functionplot(x, y; kwargs...)
Plot y over y.
Arguments:
- xvector of x coordinates
- yvector of y coordinates (function values)
Keyword arguments:
- limits=(1,-1): function limits
- xlimits=(1,-1): x axis limits
- xlabel="": x axis label
- ylabel="": y axis label
- `title="" : plot title
- xscale=:linear: linear or log scale for x axis
- yscale=:linear: linear or log scale for y axis
- legend=:none: legend placement (:lt,:rt ...)
- clear=false: clear plot contents
- label="": label of particular plot
- color=:auto
- titlefontsize=12
- axisfontsize=10
- tickfontsize=10
- legendfontsize=10
- linewidth=2
- linestyle=:solid:
- markersize=6
- markercount=10
- markertype=:none, possible values:- :dtriangle,- :utriangle,- :rtriangle,- :ltriangle,- :circle,- :square,- :cross,- :+,- :xcross,- :x,- :diamond,- :star5,- :pentagon, `:hexagon
plot(; datadim, backend, kwargs...)
Create empty 1D plot.
PlutoVista.plot! — Methodplot!(p, x, y; backend, clear, kwargs...)
Add additional x-y plot to p
2D plots
When using vtk.js (default), interactive control via mouse includes the following actions:
- Left Mouse + Shift: Pan
- Left Mouse + Ctrl/Alt: Reset camera
- Left Mouse + Shift + Ctrl/Alt: Dolly (Zoom)
- Mouse Wheel: Dolly (Zoom)
- Multi-Touch Pinch: Dolly (Zoom)
- Multi-Touch Pan: Pan
- 3D Events: Camera Pose
Compared to vtk.js, keyboard interaction and rotation have been disabled, "spin" has been replaced by "reset camera".
PlutoVista.tricontour — Functiontricontour(pts, tris, f; kwargs...)
Filled colored tricontour with isolines. By default, a vtk.js based backend is used. Plots piecewise linear function on triangular grid.
Arguments:
- pts:- 2 x n_pointsarray of point coordinates
- tris:- 3 x n_trisarray of point indices describing triangles
- f:- n-vector of function values
Keyword arguments:
- title=""
- clear=false
- xlabel="x": x axis label
- ylabel="y": y axis label
- colormap=:viridis
- levels=0: either number of interior isolevels, or vector of isolevel values
- colorbarticks=:default: colorbar ticks. Default: levels
- limits=:auto: function limits
- aspect=1: xy aspect ratio (plotly backend)
tricontour(; kwargs...)
Create empty tricontour plot
PlutoVista.tricontour! — Methodtricontour!(p, pts, tris, f; backend, kwargs...)
Add tricontour to existing plot
PlutoVista.quiver2d — Functionquiver2d(pts, qvec; kwargs...)
Quiver plot, using vtk.js backend.
Arguments:
- pts:- 2 x n_ptsarray of points
- qvec:- 2 x n_ptsarray of vector values
quiver2d(; kwargs...)
Create empty quiver plot
PlutoVista.quiver2d! — Methodquiver2d!(p, pts, qvec; backend, kwargs...)
Add quiver to existing plot
PlutoVista.trimesh — Functiontrimesh(pts, tris; kwargs...)
Plot triangular mesh, showing triangle boundaries and outer boundaries, using vtk.js backend.
Arguments:
- pts:- 2 x n_pointsarray of point coordinates
- tris:- 3 x n_trisarray of point indices describing triangles
Keyword arguments:
- markers=nothing: Optional- n_trisinteger vector of triangle markers
- colormap: optional colormap for triangle markers
- edges:- 2 x n_edgesoptional array of point indices describing edges
- edgemarkers=nothing: optional- n_edgesvector of integer edge markers
- edgecolormap=nothing: optional colormap for edge markers
- show_colorbar=true: optional show the colorbar next to the plot
trimesh(; kwargs...)
Create empty trimesh plot.
PlutoVista.trimesh! — Methodtrimesh!(p, pts, tris; backend, kwargs...)
Add trimesh to plot.
3D plots
When using vtk.js (default), interactive control via mouse includes the following actions:
- Left Mouse: Rotate
- Left Mouse + Shift: Pan
- Left Mouse + Ctrl/Alt: Reset camera
- Left Mouse + Shift + Ctrl/Alt: Dolly (Zoom)
- Mouse Wheel: Dolly (Zoom)
- Multi-Touch Rotate: Rotate
- Multi-Touch Pinch: Dolly (Zoom)
- Multi-Touch Pan: Pan
- 3D Events: Camera Pose
Compared to vtk.js, keyboard interaction has been disabled, and "spin" has been replaced by "reset camera".
PlutoVista.tetcontour — Functiontetcontour(pts, tets, f; kwargs...)
Plot piecewise linear function on tetrahedral grid using vtk backend. The plot consists of three parts:
- Transparent isosurfaces of function values according to levels
- Transparent plane cuts with function "hetmapes" according to xplanes,yplanes,zplanes
- Transparent domain outline
Arguments:
- pts:- 3 x n_pointsarray of point coordinates
- tets:- 4 x n_tetsarray of point indices describing tetrahedra
- f:- n_points-vector of function values
Keyword arguments:
- title=""
- clear=false
- colormap=:viridis
- faces=nothing: optional- 3 x n_facesarray of boundary faces
- facemarkers=nothing: optional- n_facesinteger vector of face markers
- facecolormap=nothing: optional colormap of facemarkers
- levels=0: either number of interior isolevels, or vector of isolevel values
- limits=:auto: function limits
- xplanes: either number or array of x coordinate values of x-orthogonal plane sections
- yplanes: either number or array of y coordinate values of y-orthogonal plane sections
- zplanes: either number or array of z coordinate values of z-orthogonal plane sections
- levelalpha=0.25: alpha value for isosurfaces and plane cuts
- outlinealpha=0.1: alpha value for outline. Outliene is for value 0.0
tetcontour(; kwargs...)
Create empty tetcontour plot.
PlutoVista.tetcontour! — Methodtetcontour!(p, pts, tets, f; backend, kwargs...)
Add tetcontour to plot
PlutoVista.tetmesh — Functiontetmesh(pts, tets; kwargs...)
Plot tetrahedral mesh, showing tetrahedron boundaries and outer boundaries, using vtk.js backend. The plot consists of two parts:
- A subset of tetrahedra visible after cutting of all tets with are on the positive side of the respective x, y, z planes
- A transpatemt outline of the boundary.
Arguments:
- pts:- 3 x n_pointsarray of point coordinates
- tets:- 4 x n_trisarray of point indices describing tetrahedra
Keyword arguments:
- markers=nothing: Optional- n_tetsinteger vector of tetrahedron markers
- colormap: optional colormap for tetrahedron markers
- faces=nothing: optional- 3 x n_facesarray of boundary faces
- facemarkers=nothing: optional- n_facesinteger vector of face markers
- facecolormap=nothing: optional colormap of facemarkers
- xplanes: array of x coordinate values for cut-off in x-direction
- yplanes: array of y coordinate values for cut-off in y-direction
- zplanes: array of z coordinate values for cut-off in z-direction
- outlinealpha=0.1: alpha value for outline. Outliene is for value 0.0
- show_colorbar=true: optional show the colorbar next to the plot
tetmesh(; kwargs...)
Create empty tetmesh plot.
PlutoVista.tetmesh! — Methodtetmesh!(p, pts, tets; backend, kwargs...)
Add tetmesh to plot
Pluto utilities
PlutoVista.ScreenWidthGrabber — Type@bind width ScreenWidthGrabber()Detect screen width from pluto notebook. (see https://discourse.julialang.org/t/cell-width-in-pluto-notebook/49761/3)
PlutoVista.PlutoCellWidener — TypePlutoCellWidener(px)Set pluto cell width to a given number of pixels.
(see https://discourse.julialang.org/t/cell-width-in-pluto-notebook/49761/3)
Setting width larger than standard may interfer with other Pluto functionality.