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.PlutoVistaPlotType
mutable struct PlutoVistaPlot

PlutoVistaPlot 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.

source
PlutoVista.PlutoVistaPlotMethod
PlutoVistaPlot(; resolution, kwargs...)

Constructor for PlutoVistaPlot.

Relevant keyword arguments:

  • resolution: Screen resolution in pixels
  • dim: Space dimension of subsequent plots
source

1D plots

PlutoVista.plotFunction
plot(x, y; kwargs...)

Plot y over y.

Arguments:

  • x vector of x coordinates
  • y vector 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
source
plot(; datadim, backend, kwargs...)

Create empty 1D plot.

source

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.tricontourFunction
tricontour(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_points array of point coordinates
  • tris: 3 x n_tris array 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)
source
tricontour(; kwargs...)

Create empty tricontour plot

source
PlutoVista.quiver2dFunction
quiver2d(pts, qvec; kwargs...)

Quiver plot, using vtk.js backend.

Arguments:

  • pts: 2 x n_pts array of points
  • qvec: 2 x n_pts array of vector values
source
quiver2d(; kwargs...)

Create empty quiver plot

source
PlutoVista.trimeshFunction
trimesh(pts, tris; kwargs...)

Plot triangular mesh, showing triangle boundaries and outer boundaries, using vtk.js backend.

Arguments:

  • pts: 2 x n_points array of point coordinates
  • tris: 3 x n_tris array of point indices describing triangles

Keyword arguments:

  • markers=nothing: Optional n_tris integer vector of triangle markers
  • colormap: optional colormap for triangle markers
  • edges: 2 x n_edges optional array of point indices describing edges
  • edgemarkers=nothing: optional n_edges vector of integer edge markers
  • edgecolormap=nothing: optional colormap for edge markers
source
trimesh(; kwargs...)

Create empty trimesh plot.

source

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.tetcontourFunction
tetcontour(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_points array of point coordinates
  • tets: 4 x n_tets array 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_faces array of boundary faces
  • facemarkers=nothing: optional n_faces integer 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
source
tetcontour(; kwargs...)

Create empty tetcontour plot.

source
PlutoVista.tetmeshFunction
tetmesh(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_points array of point coordinates
  • tets: 4 x n_tris array of point indices describing tetrahedra

Keyword arguments:

  • markers=nothing: Optional n_tets integer vector of tetrahedron markers
  • colormap: optional colormap for tetrahedron markers
  • faces=nothing: optional 3 x n_faces array of boundary faces
  • facemarkers=nothing: optional n_faces integer 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
source
tetmesh(; kwargs...)

Create empty tetmesh plot.

source

Pluto utilities

PlutoVista.ScreenWidthGrabberType
@bind width ScreenWidthGrabber()

Detect screen width from pluto notebook. (see https://discourse.julialang.org/t/cell-width-in-pluto-notebook/49761/3)

source
PlutoVista.PlutoCellWidenerType
PlutoCellWidener(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.

source