Exported
AbstractPlotting.Absolute
— TypeAbsolute
Force transformation to be absolute, not relative to the current state. This is the default setting.
AbstractPlotting.Accum
— TypeAccum
Force transformation to be relative to the current state, not absolute.
AbstractPlotting.Attributes
— TypeMain structure for holding attributes, for theming plots etc! Will turn all values into nodes, so that they can be updated.
AbstractPlotting.Billboard
— TypeBillboard attribute to always have a primitive face the camera. Can be used for rotation.
AbstractPlotting.Events
— TypeThis struct provides accessible Observable
s to monitor the events associated with a Scene.
Fields
window_area::Observable{GeometryBasics.HyperRectangle{2, Int64}}
The area of the window in pixels, as a
Rect2D
.
window_dpi::Observable{Float64}
The DPI resolution of the window, as a
Float64
.
window_open::Observable{Bool}
The state of the window (open => true, closed => false).
mousebuttons::Observable{Set{AbstractPlotting.Mouse.Button}}
The pressed mouse buttons. Updates when a mouse button is pressed.
See also
ispressed
.
mouseposition::Observable{Tuple{Float64, Float64}}
The position of the mouse as a
NTuple{2, Float64}
. Updates whenever the mouse moves.
mousedrag::Observable{AbstractPlotting.Mouse.DragEnum}
The state of the mouse drag, represented by an enumerator of
DragEnum
.scroll::Observable{Tuple{Float64, Float64}}
The direction of scroll
keyboardbuttons::Observable{Set{AbstractPlotting.Keyboard.Button}}
See also
ispressed
.
unicode_input::Observable{Vector{Char}}
dropped_files::Observable{Vector{String}}
hasfocus::Observable{Bool}
Whether the Scene window is in focus or not.
entered_window::Observable{Bool}
AbstractPlotting.Pixel
— TypeUnit in pixels on screen. This one is a bit tricky, since it refers to a static attribute (pixels on screen don't change) but since every visual is attached to a camera, the exact scale might change. So in the end, this is just relative to some normed camera - the value on screen, depending on the camera, will not actually sit on those pixels. Only camera that guarantees the correct mapping is the :pixel
camera type.
AbstractPlotting.PlotSpec
— TypePlotSpec{P<:AbstractPlot}(args...; kwargs...)
Object encoding positional arguments (args
), a NamedTuple
of attributes (kwargs
) as well as plot type P
of a basic plot.
AbstractPlotting.Reverse
— TypeReverses the attribute T upon conversion
AbstractPlotting.Scene
— TypeScene TODO document this
Constructors
Fields
parent
The parent of the Scene; if it is a top-level Scene,
parent == nothing
.events
Events
associated with the Scene.px_area
The current pixel area of the Scene.
clear
Whether the scene should be cleared.
camera
The
Camera
associated with the Scene.camera_controls
The controls for the camera of the Scene.
data_limits
The limits of the data plotted in this scene. Can't be set by user and is only used to store calculated data bounds.
transformation
The
Transformation
of the Scene.plots
The plots contained in the Scene.
theme
attributes
children
Children of the Scene inherit its transformation.
current_screens
The Screens which the Scene is displayed to.
updated
Signal to indicate whether layouting should happen. If updated to true, the Scene will be layouted according to its attributes (
raw
,center
, orscale_plot
).
AbstractPlotting.SceneSpace
— TypeUnit space of the scene it's displayed on. Also referred to as data units
AbstractPlotting.Transformation
— TypeHolds the transformations for Scenes.
Fields
parent::Base.RefValue{AbstractPlotting.Transformable}
translation::Observable{Vec{3, Float32}}
scale::Observable{Vec{3, Float32}}
rotation::Observable{Quaternionf0}
model::Observable{StaticArrays.SMatrix{4, 4, Float32, 16}}
flip::Observable{Tuple{Bool, Bool, Bool}}
align::Observable{Vec{2, Float32}}
transform_func::Observable{Any}
AbstractPlotting.VideoStream
— MethodVideoStream(scene::Scene, framerate = 24)
Returns a stream and a buffer that you can use, which don't allocate for new frames. Use recordframe!(stream)
to add new video frames to the stream, and save(path, stream)
to save the video.
AbstractPlotting.Pattern
— MethodPattern(image)
Pattern(mask[; color1, color2])
Creates an ImagePattern
from an image
(a matrix of colors) or a mask
(a matrix of real numbers). The pattern can be passed as a color
to a plot to texture it. If a mask
is passed, one can specify to colors between which colors are interpolated.
AbstractPlotting.Pattern
— MethodPattern(style::String = "/"; kwargs...)
Pattern(style::Char = '/'; kwargs...)
Creates a line pattern based on the given argument. Available patterns are '/'
, '\'
, '-'
, '|'
, 'x'
, and '+'
. All keyword arguments correspond to the keyword arguments for LinePattern
.
AbstractPlotting.annotations!
— Methodannotations(strings::Vector{String}, positions::Vector{Point})
Plots an array of texts at each position in positions
.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.annotations!, T} where T
are:
AbstractPlotting.annotations
— Methodannotations(strings::Vector{String}, positions::Vector{Point})
Plots an array of texts at each position in positions
.
Attributes
Available attributes and their defaults for Annotations{T} where T
are:
_glyphlayout "nothing"
align (:left, :bottom)
ambient Float32[0.55, 0.55, 0.55]
color :black
diffuse Float32[0.4, 0.4, 0.4]
font "Dejavu Sans"
justification AbstractPlotting.Automatic()
lightposition :eyeposition
lineheight 1.0
linewidth 1
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
position Float32[0.0, 0.0]
rotation 0.0
shininess 32.0f0
space :screen
specular Float32[0.2, 0.2, 0.2]
ssao false
strokecolor (:black, 0.0)
strokewidth 0
textsize 20
transparency false
visible true
AbstractPlotting.arc!
— Methodarc(origin, radius, start_angle, stop_angle; kwargs...)
This function plots a circular arc, centered at origin
with radius radius
, from start_angle
to stop_angle
. origin
must be a coordinate in 2 dimensions (i.e., a Point2
); the rest of the arguments must be <: Number
.
Examples:
arc(Point2f0(0), 1, 0.0, π)
arc(Point2f0(1, 2), 0.3. π, -π)
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.arc!, T} where T
are:
AbstractPlotting.arc
— Methodarc(origin, radius, start_angle, stop_angle; kwargs...)
This function plots a circular arc, centered at origin
with radius radius
, from start_angle
to stop_angle
. origin
must be a coordinate in 2 dimensions (i.e., a Point2
); the rest of the arguments must be <: Number
.
Examples:
arc(Point2f0(0), 1, 0.0, π)
arc(Point2f0(1, 2), 0.3. π, -π)
Attributes
Available attributes and their defaults for Arc{T} where T
are:
ambient Float32[0.55, 0.55, 0.55]
color :black
colormap :viridis
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
lightposition :eyeposition
linestyle "nothing"
linewidth 1.0
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
resolution 361
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.arrows!
— Methodarrows(points, directions; kwargs...)
arrows(x, y, u, v)
arrows(x::AbstractVector, y::AbstractVector, u::AbstractMatrix, v::AbstractMatrix)
arrows(x, y, z, u, v, w)
Plots arrows at the specified points with the specified components. u
and v
are interpreted as vector components (u
being the x and v
being the y), and the vectors are plotted with the tails at x
, y
.
If x, y, u, v
are <: AbstractVector
, then each 'row' is plotted as a single vector.
If u, v
are <: AbstractMatrix
, then x
and y
are interpreted as specifications for a grid, and u, v
are plotted as arrows along the grid.
arrows
can also work in three dimensions.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.arrows!, T} where T
are:
AbstractPlotting.arrows
— Methodarrows(points, directions; kwargs...)
arrows(x, y, u, v)
arrows(x::AbstractVector, y::AbstractVector, u::AbstractMatrix, v::AbstractMatrix)
arrows(x, y, z, u, v, w)
Plots arrows at the specified points with the specified components. u
and v
are interpreted as vector components (u
being the x and v
being the y), and the vectors are plotted with the tails at x
, y
.
If x, y, u, v
are <: AbstractVector
, then each 'row' is plotted as a single vector.
If u, v
are <: AbstractMatrix
, then x
and y
are interpreted as specifications for a grid, and u, v
are plotted as arrows along the grid.
arrows
can also work in three dimensions.
Attributes
Available attributes and their defaults for Arrows{T} where T
are:
arrowcolor :black
arrowhead AbstractPlotting.Automatic()
arrowsize 0.3
arrowtail "nothing"
colormap :viridis
lengthscale 1.0f0
linecolor :black
linestyle "nothing"
linewidth 1
normalize false
scale Float32[1.0, 1.0, 1.0]
AbstractPlotting.available_gradients
— Methodavailable_gradients()
Prints all available gradient names.
AbstractPlotting.axis3d!
— Methodaxis3d!(args; attributes...)
Plots a 3-dimensional OldAxis.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.axis3d!, T} where T
are:
AbstractPlotting.axis3d
— Methodaxis3d(args; attributes...)
Plots a 3-dimensional OldAxis.
Attributes
OldAxis attributes and their defaults for Axis3D{T} where T
are:
showaxis: (true, true, true)
showgrid: (true, true, true)
padding: 0.1
visible: true
ticks:
rotation: (-0.7071067811865475 + -0.0im + -0.0jm - 0.7071067811865476km, -4.371139e-8 + 0.0im + 0.0jm + 1.0km, -3.090861907263062e-8 + 3.090861907263061e-8im + 0.7071067811865475jm + 0.7071067811865476km)
font: ("Dejavu Sans", "Dejavu Sans", "Dejavu Sans")
ranges_labels: (AbstractPlotting.Automatic(), AbstractPlotting.Automatic())
formatter: plain
textcolor: (RGBA{Float32}(0.5f0,0.5f0,0.5f0,0.6f0), RGBA{Float32}(0.5f0,0.5f0,0.5f0,0.6f0), RGBA{Float32}(0.5f0,0.5f0,0.5f0,0.6f0))
align: ((:left, :center), (:right, :center), (:right, :center))
textsize: (5, 5, 5)
gap: 3
frame:
axiscolor: (:black, :black, :black)
axislinewidth: (1.5, 1.5, 1.5)
linewidth: (1, 1, 1)
linecolor: (RGBA{Float32}(0.5f0,0.5f0,0.5f0,0.4f0), RGBA{Float32}(0.5f0,0.5f0,0.5f0,0.4f0), RGBA{Float32}(0.5f0,0.5f0,0.5f0,0.4f0))
names:
axisnames: ("x", "y", "z")
rotation: (-0.7071067811865475 + -0.0im + -0.0jm - 0.7071067811865476km, -4.371139e-8 + 0.0im + 0.0jm + 1.0km, -3.090861907263062e-8 + 3.090861907263061e-8im + 0.7071067811865475jm + 0.7071067811865476km)
font: ("Dejavu Sans", "Dejavu Sans", "Dejavu Sans")
textcolor: (:black, :black, :black)
align: ((:left, :center), (:right, :center), (:right, :center))
textsize: (6.0, 6.0, 6.0)
gap: 3
showticks: (true, true, true)
scale: Float32[1.0, 1.0, 1.0]
AbstractPlotting.band!
— Methodband(x, ylower, yupper; kwargs...) band(lower, upper; kwargs...)
Plots a band from ylower
to yupper
along x
.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.band!, T} where T
are:
AbstractPlotting.band
— Methodband(x, ylower, yupper; kwargs...) band(lower, upper; kwargs...)
Plots a band from ylower
to yupper
along x
.
Attributes
Available attributes and their defaults for Band{T} where T
are:
ambient Float32[0.55, 0.55, 0.55]
color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.2f0)
colormap :viridis
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
interpolate false
lightposition :eyeposition
linewidth 1
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
shading true
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.barplot!
— Methodbarplot(x, y; kwargs...)
Plots a barplot; y
defines the height. x
and y
should be 1 dimensional.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.barplot!, T} where T
are:
AbstractPlotting.barplot
— Methodbarplot(x, y; kwargs...)
Plots a barplot; y
defines the height. x
and y
should be 1 dimensional.
Attributes
Available attributes and their defaults for BarPlot{T} where T
are:
color :black
colormap :viridis
colorrange AbstractPlotting.Automatic()
direction :y
fillto 0.0
marker GeometryBasics.HyperRectangle
strokecolor :white
strokewidth 0
visible true
width AbstractPlotting.Automatic()
AbstractPlotting.boxplot!
— Methodboxplot(x, y; kwargs...)
Draw a Tukey style boxplot. The boxplot has 3 components:
- a
crossbar
spanning the interquartile (IQR) range with a midline marking the median - an
errorbar
whose whiskers spanrange * iqr
- points marking outliers, that is, data outside the whiskers
Arguments
x
: positions of the categoriesy
: variables within the boxes
Keywords
orientation=:vertical
: orientation of box (:vertical
or:horizontal
)width=0.8
: width of the boxshow_notch=false
: draw the notchnotchwidth=0.5
: multiplier ofwidth
for narrowest width of notchshow_median=true
: show median as midlinerange
: multiple of IQR controlling whisker lengthwhiskerwidth
: multiplier ofwidth
for width of T's on whiskers, or:match
to matchwidth
show_outliers
: show outliers as points
AbstractPlotting.boxplot
— Methodboxplot(x, y; kwargs...)
Draw a Tukey style boxplot. The boxplot has 3 components:
- a
crossbar
spanning the interquartile (IQR) range with a midline marking the median - an
errorbar
whose whiskers spanrange * iqr
- points marking outliers, that is, data outside the whiskers
Arguments
x
: positions of the categoriesy
: variables within the boxes
Keywords
orientation=:vertical
: orientation of box (:vertical
or:horizontal
)width=0.8
: width of the boxshow_notch=false
: draw the notchnotchwidth=0.5
: multiplier ofwidth
for narrowest width of notchshow_median=true
: show median as midlinerange
: multiple of IQR controlling whisker lengthwhiskerwidth
: multiplier ofwidth
for width of T's on whiskers, or:match
to matchwidth
show_outliers
: show outliers as points
AbstractPlotting.broadcast_foreach
— MethodLike broadcast but for foreach. Doesn't care about shape and treats Tuples && StaticVectors as scalars.
AbstractPlotting.cam2d!
— Methodcam2d!(scene::SceneLike, kwargs...)
Creates a 2D camera for the given Scene.
AbstractPlotting.cam2d
— MethodCreates a subscene with a pixel camera
AbstractPlotting.cam3d!
— Functioncam3d!(scene; kwargs...)
An alias to cam3d_turntable!
. Creates a 3D camera for scene
, which rotates around the plot's axis.
AbstractPlotting.cam3d_cad!
— Methodcam3d_cad!(scene; kw_args...)
Creates a 3D camera for scene
which rotates around the viewer's "up" axis - similarly to how it's done in CAD software cameras.
AbstractPlotting.campixel!
— Methodcampixel!(scene)
Creates a pixel-level camera for the Scene
. No controls!
AbstractPlotting.contour!
— Methodcontour(x, y, z)
Creates a contour plot of the plane spanning x::Vector, y::Vector, z::Matrix
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.contour!, T} where T
are:
AbstractPlotting.contour
— Methodcontour(x, y, z)
Creates a contour plot of the plane spanning x::Vector, y::Vector, z::Matrix
Attributes
Available attributes and their defaults for Contour{T} where T
are:
alpha 1.0
ambient Float32[0.55, 0.55, 0.55]
color "nothing"
colormap :viridis
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
fillrange false
levels 5
lightposition :eyeposition
linewidth 1.0
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.contour3d!
— Methodcontour3d(x, y, z)
Creates a 3D contour plot of the plane spanning x::Vector, y::Vector, z::Matrix, with z-elevation for each level.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.contour3d!, T} where T
are:
AbstractPlotting.contour3d
— Methodcontour3d(x, y, z)
Creates a 3D contour plot of the plane spanning x::Vector, y::Vector, z::Matrix, with z-elevation for each level.
Attributes
Available attributes and their defaults for Contour3d{T} where T
are:
alpha 1.0
ambient Float32[0.55, 0.55, 0.55]
color "nothing"
colormap :viridis
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
fillrange false
levels 5
lightposition :eyeposition
linewidth 1.0
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.contourf!
— Methodcontourf(xs, ys, zs; kwargs...)
Plots a filled contour of the height information in zs
at horizontal grid positions xs
and vertical grid positions ys
.
The attribute levels
can be either
- an
Int
that produces n equally wide levels or bands - an
AbstractVector{<:Real}
that lists n consecutive edges from low to high, which result in n-1 levels or bands
If you want to show a band from -Inf
to the low edge, set extendlow
to :auto
for the same color as the first level, or specify a different color (default nothing
means no extended band) If you want to show a band from the high edge to Inf
, set extendhigh
to :auto
for the same color as the last level, or specify a different color (default nothing
means no extended band)
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.contourf!, T} where T
are:
AbstractPlotting.contourf
— Methodcontourf(xs, ys, zs; kwargs...)
Plots a filled contour of the height information in zs
at horizontal grid positions xs
and vertical grid positions ys
.
The attribute levels
can be either
- an
Int
that produces n equally wide levels or bands - an
AbstractVector{<:Real}
that lists n consecutive edges from low to high, which result in n-1 levels or bands
If you want to show a band from -Inf
to the low edge, set extendlow
to :auto
for the same color as the first level, or specify a different color (default nothing
means no extended band) If you want to show a band from the high edge to Inf
, set extendhigh
to :auto
for the same color as the last level, or specify a different color (default nothing
means no extended band)
Attributes
Available attributes and their defaults for Contourf{T} where T
are:
colormap :viridis
extendhigh "nothing"
extendlow "nothing"
levels 10
AbstractPlotting.convert_arguments
— MethodEnables to use scatter like a surface plot with x::Vector, y::Vector, z::Matrix spanning z over the grid spanned by x y
AbstractPlotting.convert_arguments
— Methodconvert_arguments(P, x, y, z)::(Vector)
Takes vectors x
, y
, and z
and turns it into a vector of 3D points of the values from x
, y
, and z
. P
is the plot Type (it is optional).
AbstractPlotting.convert_arguments
— Methodconvert_arguments(P, x, y)::(Vector)
Takes vectors x
and y
and turns it into a vector of 2D points of the values from x
and y
.
P
is the plot Type (it is optional).
AbstractPlotting.convert_arguments
— Methodconvert_arguments(P, y)::Vector
Takes vector y
and generates a range from 1 to the length of y
, for plotting on an arbitrary x
axis.
P
is the plot Type (it is optional).
AbstractPlotting.convert_arguments
— Methodconvert_arguments(P, x)::(Vector)
Takes an input GeometryPrimitive x
and decomposes it to points. P
is the plot Type (it is optional).
AbstractPlotting.convert_arguments
— Methodconvert_arguments(PB, LineString)
Takes an input LineString
and decomposes it to points.
AbstractPlotting.convert_arguments
— Methodconvert_arguments(PB, Polygon)
Takes an input Polygon
and decomposes it to points.
AbstractPlotting.convert_arguments
— Methodconvert_arguments(P, x)::(Vector)
Takes an input Rect
x
and decomposes it to points.
P
is the plot Type (it is optional).
AbstractPlotting.convert_arguments
— Methodconvert_arguments(PB, Union{Array{<:LineString}, MultiLineString})
Takes an input Array{LineString}
or a MultiLineString
and decomposes it to points.
AbstractPlotting.convert_arguments
— Methodconvert_arguments(PB, Union{Array{<:Polygon}, MultiPolygon})
Takes an input Array{Polygon}
or a MultiPolygon
and decomposes it to points.
AbstractPlotting.convert_arguments
— Methodconvert_arguments(P, Matrix)::Tuple{ClosedInterval, ClosedInterval, Matrix}
Takes an AbstractMatrix
, converts the dimesions n
and m
into ClosedInterval
, and stores the ClosedInterval
to n
and m
, plus the original matrix in a Tuple.
P
is the plot Type (it is optional).
AbstractPlotting.convert_arguments
— Methodconvert_arguments(P, x::VecOrMat, y::VecOrMat, z::Matrix)
Takes 3 AbstractMatrix
x
, y
, and z
, converts them to Float32
and outputs them in a Tuple.
P
is the plot Type (it is optional).
AbstractPlotting.convert_arguments
— Methodconvert_arguments(P, x, y, z)::Tuple{ClosedInterval, ClosedInterval, Matrix}
Takes 2 ClosedIntervals's x
, y
, and an AbstractMatrix z
, and converts the closed range to linspaces with size(z, 1/2) P
is the plot Type (it is optional).
AbstractPlotting.convert_arguments
— Methodconvert_arguments(P, x, y, z, f)::(Vector, Vector, Vector, Matrix)
Takes AbstractVector
x
, y
, and z
and the function f
, evaluates f
on the volume spanned by x
, y
and z
, and puts x
, y
, z
and f(x,y,z)
in a Tuple.
P
is the plot Type (it is optional).
AbstractPlotting.convert_arguments
— Methodconvert_arguments(x)::(String)
Takes an input AbstractString
x
and converts it to a string.
AbstractPlotting.convert_arguments
— Methodconvert_arguments(Mesh, vertices, indices)::GLNormalMesh
Takes vertices
and indices
, and creates a triangle mesh out of those. See to_vertices
and to_triangles
for more information about accepted types.
AbstractPlotting.convert_arguments
— Methodconvert_arguments(Mesh, x, y, z, indices)::GLNormalMesh
Takes real vectors x, y, z and constructs a triangle mesh out of those, using the faces in indices
, which can be integers (every 3 -> one triangle), or GeometryBasics.NgonFace{N, <: Integer}.
AbstractPlotting.convert_arguments
— Methodconvert_arguments(Mesh, x, y, z)::GLNormalMesh
Takes real vectors x, y, z and constructs a mesh out of those, under the assumption that every 3 points form a triangle.
AbstractPlotting.convert_arguments
— Methodconvert_arguments(Mesh, xyz::AbstractVector)::GLNormalMesh
Takes an input mesh and a vector xyz
representing the vertices of the mesh, and creates indices under the assumption, that each triplet in xyz
forms a triangle.
AbstractPlotting.convert_arguments
— MethodAccepts a Vector of Pair of Points (e.g. [Point(0, 0) => Point(1, 1), ...]
) to encode e.g. linesegments or directions.
AbstractPlotting.convert_arguments
— MethodWrap a single point or equivalent object in a single-element array.
AbstractPlotting.convert_arguments
— Methodconvert_arguments(P, x, y, f)::(Vector, Vector, Matrix)
Takes vectors x
and y
and the function f
, and applies f
on the grid that x
and y
span. This is equivalent to f.(x, y')
. P
is the plot Type (it is optional).
AbstractPlotting.convert_arguments
— Methodconvert_arguments(P, Matrix)::Tuple{ClosedInterval, ClosedInterval, ClosedInterval, Matrix}
Takes an array of {T, 3} where T
, converts the dimesions n
, m
and k
into ClosedInterval
, and stores the ClosedInterval
to n
, m
and k
, plus the original array in a Tuple.
P
is the plot Type (it is optional).
AbstractPlotting.convert_arguments
— Methodconvert_arguments(P, x, y, z, i)::(Vector, Vector, Vector, Matrix)
Takes 3 AbstractVector
x
, y
, and z
and the AbstractMatrix
i
, and puts everything in a Tuple.
P
is the plot Type (it is optional).
AbstractPlotting.convert_attribute
— FunctionTuple(A, B) or Pair{A, B} with any object that to_color
accepts
AbstractPlotting.convert_attribute
— Functionto_colormap(b, x)
An AbstractVector{T}
with any object that to_color
accepts.
AbstractPlotting.convert_attribute
— FunctionA Symbol/String naming the gradient. For more on what names are available please see: available_gradients()
. For now, we support gradients from PlotUtils
natively.
AbstractPlotting.convert_attribute
— Method`AbstractVector{<:AbstractFloat}` for denoting sequences of fill/nofill. e.g.
[0.5, 0.8, 1.2] will result in 0.5 filled, 0.3 unfilled, 0.4 filled. 1.0 unit is one linewidth!
AbstractPlotting.convert_attribute
— Methodto_volume_algorithm(b, x)
Enum values: IsoValue
Absorption
MaximumIntensityProjection
AbsorptionRGBA
AdditiveRGBA
IndexedAbsorptionRGBA
AbstractPlotting.convert_attribute
— Methodrotation accepts:
to_rotation(b, quaternion)
to_rotation(b, tuple_float)
to_rotation(b, vec4)
AbstractPlotting.convert_attribute
— MethodText align, e.g.:
AbstractPlotting.convert_attribute
— MethodA `Symbol` equal to `:dash`, `:dot`, `:dashdot`, `:dashdotdot`
AbstractPlotting.convert_attribute
— MethodSymbol/String: iso, absorption, mip, absorptionrgba, indexedabsorption
AbstractPlotting.convert_attribute
— Methodfont conversion
a string naming a font, e.g. helvetica
AbstractPlotting.crossbar!
— Methodcrossbar(x, y, ymin, ymax; kwargs...) Draw a crossbar. A crossbar represents a range with a (potentially notched) box. It is most commonly used as part of the boxplot
.
Arguments
x
: position of the boxy
: position of the midline within the boxymin
: lower limit of the boxymax
: upper limit of the box
Keywords
orientation=:vertical
: orientation of box (:vertical
or:horizontal
)width=0.8
: width of the boxshow_notch=false
: draw the notchnotchmin=automatic
: lower limit of the notchnotchmax=automatic
: upper limit of the notchnotchwidth=0.5
: multiplier ofwidth
for narrowest width of notchshow_midline=true
: show midline
AbstractPlotting.crossbar
— Methodcrossbar(x, y, ymin, ymax; kwargs...) Draw a crossbar. A crossbar represents a range with a (potentially notched) box. It is most commonly used as part of the boxplot
.
Arguments
x
: position of the boxy
: position of the midline within the boxymin
: lower limit of the boxymax
: upper limit of the box
Keywords
orientation=:vertical
: orientation of box (:vertical
or:horizontal
)width=0.8
: width of the boxshow_notch=false
: draw the notchnotchmin=automatic
: lower limit of the notchnotchmax=automatic
: upper limit of the notchnotchwidth=0.5
: multiplier ofwidth
for narrowest width of notchshow_midline=true
: show midline
AbstractPlotting.density!
— Methoddensity(values; npoints = 200, offset = 0.0, direction = :x)
Plot a kernel density estimate of values
. npoints
controls the resolution of the estimate, the baseline can be shifted with offset
and the direction
set to :x or :y. bandwidth
and boundary
are determined automatically by default.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.density!, T} where T
are:
AbstractPlotting.density
— Methoddensity(values; npoints = 200, offset = 0.0, direction = :x)
Plot a kernel density estimate of values
. npoints
controls the resolution of the estimate, the baseline can be shifted with offset
and the direction
set to :x or :y. bandwidth
and boundary
are determined automatically by default.
Attributes
Available attributes and their defaults for Density{T} where T
are:
bandwidth AbstractPlotting.Automatic()
boundary AbstractPlotting.Automatic()
color :gray85
direction :x
npoints 200
offset 0.0
strokearound false
strokecolor :black
strokewidth 1
AbstractPlotting.errorbars!
— Methoderrorbars(x, y, error_both; kwargs...)
errorbars(x, y, error_low, error_high; kwargs...)
errorbars(x, y, error_low_high; kwargs...)
errorbars(xy, error_both; kwargs...)
errorbars(xy, error_low, error_high; kwargs...)
errorbars(xy, error_low_high; kwargs...)
errorbars(xy_error_both; kwargs...)
errorbars(xy_error_low_high; kwargs...)
Plots errorbars at xy positions, extending by errors in the given direction
.
If you want to plot intervals from low to high values instead of relative errors, use rangebars
.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.errorbars!, T} where T
are:
AbstractPlotting.errorbars
— Methoderrorbars(x, y, error_both; kwargs...)
errorbars(x, y, error_low, error_high; kwargs...)
errorbars(x, y, error_low_high; kwargs...)
errorbars(xy, error_both; kwargs...)
errorbars(xy, error_low, error_high; kwargs...)
errorbars(xy, error_low_high; kwargs...)
errorbars(xy_error_both; kwargs...)
errorbars(xy_error_low_high; kwargs...)
Plots errorbars at xy positions, extending by errors in the given direction
.
If you want to plot intervals from low to high values instead of relative errors, use rangebars
.
Attributes
Available attributes and their defaults for Errorbars{T} where T
are:
color :black
colormap :viridis
direction :y
linewidth 1
visible true
whiskerwidth 10
AbstractPlotting.fill_between!
— Methodfill_between!(x, y1, y2; where = nothing, scene = current_scene(), kw_args...)
fill the section between 2 lines with the condition where
AbstractPlotting.force_update!
— MethodForces the scene to be re-rendered
AbstractPlotting.heatmap!
— Methodheatmap(x, y, values)
heatmap(values)
Plots a heatmap as an image on x, y
(defaults to interpretation as dimensions).
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.heatmap!, T} where T
are:
AbstractPlotting.heatmap
— Methodheatmap(x, y, values)
heatmap(values)
Plots a heatmap as an image on x, y
(defaults to interpretation as dimensions).
Attributes
Available attributes and their defaults for Heatmap{T} where T
are:
ambient Float32[0.55, 0.55, 0.55]
color :black
colormap :viridis
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
highclip "nothing"
interpolate false
levels 1
lightposition :eyeposition
linewidth 0.0
lowclip "nothing"
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.help
— Methodhelp(func[; extended = false])
Welcome to the main help function of Makie.jl
/ AbstractPlotting.jl
.
For help on a specific function's arguments, type help_arguments(function_name)
.
For help on a specific function's attributes, type help_attributes(plot_Type)
.
Use the optional extended = true
keyword argument to see more details.
AbstractPlotting.help_arguments
— Methodhelp_arguments([io], func)
Returns a list of signatures for function func
.
AbstractPlotting.help_attributes
— Methodhelp_attributes([io], Union{PlotType, PlotFunction}; extended = false)
Returns a list of attributes for the plot type Typ
. The attributes returned extend those attributes found in the default_theme
.
Use the optional keyword argument extended
(default = false
) to show in addition the default values of each attribute. usage:
>help_attributes(scatter)
alpha
color
colormap
colorrange
distancefield
glowcolor
glowwidth
linewidth
marker
marker_offset
markersize
overdraw
rotations
strokecolor
strokewidth
transform_marker
transparency
uv_offset_width
visible
AbstractPlotting.hist!
— Methodhist(values; bins = 15, normalization = :none)
Plot a histogram of values
. bins
can be an Int
to create that number of equal-width bins over the range of values
. Alternatively, it can be a sorted iterable of bin edges. The histogram can be normalized by setting normalization
. Possible values are:
:pdf
: Normalize by sum of weights and bin sizes. Resulting histogram has norm 1 and represents a PDF.:density
: Normalize by bin sizes only. Resulting histogram represents count density of input and does not have norm 1. Will not modify the histogram if it already represents a density (h.isdensity == 1
).:probability
: Normalize by sum of weights only. Resulting histogram represents the fraction of probability mass for each bin and does not have norm 1.:none
: Do not normalize.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.hist!, T} where T
are:
AbstractPlotting.hist
— Methodhist(values; bins = 15, normalization = :none)
Plot a histogram of values
. bins
can be an Int
to create that number of equal-width bins over the range of values
. Alternatively, it can be a sorted iterable of bin edges. The histogram can be normalized by setting normalization
. Possible values are:
:pdf
: Normalize by sum of weights and bin sizes. Resulting histogram has norm 1 and represents a PDF.:density
: Normalize by bin sizes only. Resulting histogram represents count density of input and does not have norm 1. Will not modify the histogram if it already represents a density (h.isdensity == 1
).:probability
: Normalize by sum of weights only. Resulting histogram represents the fraction of probability mass for each bin and does not have norm 1.:none
: Do not normalize.
Attributes
Available attributes and their defaults for Hist{T} where T
are:
bins 15
normalization :none
AbstractPlotting.hovered_scene
— Methodhovered_scene()
Return the scene
that the mouse is currently hovering over.
Properly identifies the scene for a plot with multiple sub-plots.
AbstractPlotting.image!
— Methodimage(x, y, image)
image(image)
Plots an image on range x, y
(defaults to dimensions).
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.image!, T} where T
are:
AbstractPlotting.image
— Methodimage(x, y, image)
image(image)
Plots an image on range x, y
(defaults to dimensions).
Attributes
Available attributes and their defaults for Image{T} where T
are:
ambient Float32[0.55, 0.55, 0.55]
color :black
colormap [:black, :white]
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
highclip "nothing"
interpolate true
lightposition :eyeposition
linewidth 1
lowclip "nothing"
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.ispressed
— Methodispressed(scene, button)
Returns true if button
is pressed in the given scene
. The button
can be a Keyboard
button (e.g. Keyboard.a
), a Mouse
button (e.g. Mouse.left
) or nothing
. In the latter case true
is always returned.
AbstractPlotting.ispressed
— Methodispressed(scene, buttons)
Returns true if all buttons
are pressed in the given scene
. buttons
can be a Vector
or Tuple
of Keyboard
buttons (e.g. Keyboard.a
), Mouse
buttons (e.g. Mouse.left
) and nothing
.
AbstractPlotting.lift
— Methodlift(f, o1::Observables.AbstractObservable, rest...; init = f(to_value(o1), to_value.(rest)...), typ = typeof(init))
Create a new Observable
by applying f
to all observables in o1
and rest...
. By default, the initial value init
is determined by the first function evaluation. You can also set typ
to control the parametric type of the Observable irrespective of the init
value.
AbstractPlotting.lines!
— Methodlines(positions)
lines(x, y)
lines(x, y, z)
Creates a connected line plot for each element in (x, y, z)
, (x, y)
or positions
.
You can separate segments by inserting NaN
s.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.lines!, T} where T
are:
AbstractPlotting.lines
— Methodlines(positions)
lines(x, y)
lines(x, y, z)
Creates a connected line plot for each element in (x, y, z)
, (x, y)
or positions
.
You can separate segments by inserting NaN
s.
Attributes
Available attributes and their defaults for Lines{T} where T
are:
ambient Float32[0.55, 0.55, 0.55]
color :black
colormap :viridis
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
lightposition :eyeposition
linestyle "nothing"
linewidth 1.0
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.linesegments!
— Methodlinesegments(positions)
linesegments(x, y)
linesegments(x, y, z)
Plots a line for each pair of points in (x, y, z)
, (x, y)
, or positions
.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.linesegments!, T} where T
are:
AbstractPlotting.linesegments
— Methodlinesegments(positions)
linesegments(x, y)
linesegments(x, y, z)
Plots a line for each pair of points in (x, y, z)
, (x, y)
, or positions
.
Attributes
Available attributes and their defaults for LineSegments{T} where T
are:
ambient Float32[0.55, 0.55, 0.55]
color :black
colormap :viridis
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
lightposition :eyeposition
linestyle "nothing"
linewidth 1.0
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.map_once
— Methodmap_once(closure, inputs::Node....)::Node
Like Reactive.foreach, in the sense that it will be preserved even if no reference is kept. The difference is, that you can call map once multiple times with the same closure and it will close the old result Node and register a new one instead.
``` function test(s1::Node) s3 = maponce(x-> (println("1 ", x); x), s1) s3 = maponce(x-> (println("2 ", x); x), s1)
end test(Node(1), Node(2))
AbstractPlotting.mesh!
— Methodmesh(x, y, z)
mesh(mesh_object)
mesh(x, y, z, faces)
mesh(xyz, faces)
Plots a 3D or 2D mesh.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.mesh!, T} where T
are:
AbstractPlotting.mesh
— Methodmesh(x, y, z)
mesh(mesh_object)
mesh(x, y, z, faces)
mesh(xyz, faces)
Plots a 3D or 2D mesh.
Attributes
Available attributes and their defaults for Mesh{T} where T
are:
ambient Float32[0.55, 0.55, 0.55]
color :black
colormap :viridis
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
interpolate false
lightposition :eyeposition
linewidth 1
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
shading true
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.meshscatter!
— Methodmeshscatter(positions)
meshscatter(x, y)
meshscatter(x, y, z)
Plots a mesh for each element in (x, y, z)
, (x, y)
, or positions
(similar to scatter
). markersize
is a scaling applied to the primitive passed as marker
.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.meshscatter!, T} where T
are:
AbstractPlotting.meshscatter
— Methodmeshscatter(positions)
meshscatter(x, y)
meshscatter(x, y, z)
Plots a mesh for each element in (x, y, z)
, (x, y)
, or positions
(similar to scatter
). markersize
is a scaling applied to the primitive passed as marker
.
Attributes
Available attributes and their defaults for MeshScatter{T} where T
are:
ambient Float32[0.55, 0.55, 0.55]
color :black
colormap :viridis
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
lightposition :eyeposition
linewidth 1
marker Sphere{Float32}(Float32[0.0, 0.0, 0.0], 1.0f0)
markersize 0.1
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
rotations 1.0 + 0.0im + 0.0jm + 0.0km
shading true
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.mouse_selection
— Methodmouse_selection(scene::Scene)
Returns the plot that is under the current mouse position
AbstractPlotting.mouseover
— Methodmouseover(scene::SceneLike, plots::AbstractPlot...)
Returns true if the mouse currently hovers any of plots
.
AbstractPlotting.mouseposition
— Functionmouseposition(scene = hovered_scene()) -> pos
Return the current position of the mouse pos
in data points of the given scene
.
By default uses the scene
that the mouse is currently hovering over.
AbstractPlotting.must_update
— MethodReturns whether a scene needs to be updated
AbstractPlotting.onpick
— Functiononpick(func, plot)
Calls func
if one clicks on plot
. Implemented by the backend.
AbstractPlotting.onpick
— Methodonpick(f, scene::SceneLike, plots::AbstractPlot...)
Calls f(idx)
whenever the mouse is over any of plots
. idx
is an index, e.g. when over a scatter plot, it will be the index of the hovered element
AbstractPlotting.pick
— FunctionPicks a mouse position. Implemented by the backend.
AbstractPlotting.pick
— Methodpick(scene::Scene, xy::VecLike[, range])
Return the plot under pixel position xy
AbstractPlotting.pick
— MethodReturn the plot under pixel position x y
AbstractPlotting.pie!
— Methodpie(fractions; kwargs...)
Creates a pie chart with the given fractions
.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.pie!, T} where T
are:
AbstractPlotting.pie
— Methodpie(fractions; kwargs...)
Creates a pie chart with the given fractions
.
Attributes
Available attributes and their defaults for Pie{T} where T
are:
color :gray
inner_radius 0
normalize true
offset 0
radius 1
strokecolor :black
strokewidth 1
vertex_per_deg 1
AbstractPlotting.plot!
— MethodMain plotting signatures that plot/plot! route to if no Plot Type is given
AbstractPlotting.poly!
— Methodpoly(vertices, indices; kwargs...)
poly(points; kwargs...)
poly(shape; kwargs...)
poly(mesh; kwargs...)
Plots a polygon based on the arguments given. When vertices and indices are given, it functions similarly to mesh
. When points are given, it draws one polygon that connects all the points in order. When a shape is given (essentially anything decomposable by GeometryBasics
), it will plot decompose(shape)
.
poly(coordinates, connectivity; kwargs...)
Plots polygons, which are defined by coordinates
(the coordinates of the vertices) and connectivity
(the edges between the vertices).
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.poly!, T} where T
are:
AbstractPlotting.poly
— Methodpoly(vertices, indices; kwargs...)
poly(points; kwargs...)
poly(shape; kwargs...)
poly(mesh; kwargs...)
Plots a polygon based on the arguments given. When vertices and indices are given, it functions similarly to mesh
. When points are given, it draws one polygon that connects all the points in order. When a shape is given (essentially anything decomposable by GeometryBasics
), it will plot decompose(shape)
.
poly(coordinates, connectivity; kwargs...)
Plots polygons, which are defined by coordinates
(the coordinates of the vertices) and connectivity
(the edges between the vertices).
Attributes
Available attributes and their defaults for Poly{T} where T
are:
color :black
colormap :viridis
colorrange AbstractPlotting.Automatic()
linestyle "nothing"
overdraw false
shading false
strokecolor RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
strokewidth 1.0
transparency false
visible true
AbstractPlotting.rangebars!
— Methodrangebars(val, low, high; kwargs...)
rangebars(val, low_high; kwargs...)
rangebars(val_low_high; kwargs...)
Plots rangebars at val
in one dimension, extending from low
to high
in the other dimension given the chosen direction
.
If you want to plot errors relative to a reference value, use errorbars
.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.rangebars!, T} where T
are:
AbstractPlotting.rangebars
— Methodrangebars(val, low, high; kwargs...)
rangebars(val, low_high; kwargs...)
rangebars(val_low_high; kwargs...)
Plots rangebars at val
in one dimension, extending from low
to high
in the other dimension given the chosen direction
.
If you want to plot errors relative to a reference value, use errorbars
.
Attributes
Available attributes and their defaults for Rangebars{T} where T
are:
color :black
colormap :viridis
direction :y
linewidth 1
visible true
whiskerwidth 10
AbstractPlotting.record
— Methodrecord(func, scene, path; framerate = 24, compression = 20)
record(func, scene, path, iter;
framerate = 24, compression = 20, sleep = true)
The first signature provides func
with a VideoStream, which it should call recordframe!(io)
on when recording a frame.
Records the Scene scene
after the application of func
on it for each element in itr
(any iterator). func
must accept an element of itr
.
The animation is then saved to path
, with the format determined by path
's extension. Allowable extensions are:
.mkv
(the default, doesn't need to convert).mp4
(good for Web, most supported format).webm
(smallest file size).gif
(largest file size for the same quality)
.mp4
and .mk4
are marginally bigger and .gif
s are up to 6 times bigger with the same quality!
The compression
argument controls the compression ratio; 51
is the highest compression, and 0
is the lowest (lossless).
When sleep
is set to true
(the default), AbstractPlotting will display the animation in real-time by sleeping in between frames. Thus, a 24-frame, 24-fps recording would take one second to record.
When it is set to false
, frames are rendered as fast as the backend can render them. Thus, a 24-frame, 24-fps recording would usually take much less than one second in GLMakie.
Typical usage patterns would look like:
record(scene, "video.mp4", itr) do i
func(i) # or some other manipulation of the Scene
end
or, for more tweakability,
record(scene, "test.gif") do io
for i = 1:100
func!(scene) # animate scene
recordframe!(io) # record a new frame
end
end
If you want a more tweakable interface, consider using VideoStream
and save
.
Extended help
Examples
scene = lines(rand(10))
record(scene, "test.gif") do io
for i in 1:255
scene.plots[:color] = Colors.RGB(i/255, (255 - i)/255, 0) # animate scene
recordframe!(io)
end
end
or
scene = lines(rand(10))
record(scene, "test.gif", 1:255) do i
scene.plots[:color] = Colors.RGB(i/255, (255 - i)/255, 0) # animate scene
end
AbstractPlotting.record_events
— Methodrecord_events(f, scene::Scene, path::String)
Records all window events that happen while executing function f
for scene
and serializes them to path
.
AbstractPlotting.recordframe!
— Methodrecordframe!(io::VideoStream)
Adds a video frame to the VideoStream io
.
AbstractPlotting.replace_automatic!
— MethodLike get!(f, dict, key)
but also calls f
and replaces key
when the corresponding value is nothing
AbstractPlotting.replay_events
— Methodreplay_events(f, scene::Scene, path::String)
replay_events(scene::Scene, path::String)
Replays the serialized events recorded with record_events
in path
in scene
.
AbstractPlotting.rotate!
— Methodrotate!(scene::Transformable, axis_rot::Quaternion)
rotate!(scene::Transformable, axis_rot::AbstractFloat)
rotate!(scene::Transformable, axis_rot...)
Apply an absolute rotation to the Scene. Rotations are all internally converted to Quaternion
s.
AbstractPlotting.rotate!
— Methodrotate!(Accum, scene::Transformable, axis_rot...)
Apply a relative rotation to the Scene, by multiplying by the current rotation.
AbstractPlotting.rotate_cam!
— Methodrotate_cam!(scene::Scene, theta_v::Number...)
rotate_cam!(scene::Scene, theta_v::VecTypes)
Rotate the camera of the Scene by the given rotation. Passing theta_v = (α, β, γ)
will rotate the camera according to the Euler angles (α, β, γ).
AbstractPlotting.scale!
— Methodscale!(t::Transformable, x, y)
scale!(t::Transformable, x, y, z)
scale!(t::Transformable, xyz)
scale!(t::Transformable, xyz...)
Scale the given Transformable
(a Scene or Plot) to the given arguments. Can take x, y
or x, y, z
. This is an absolute scaling, and there is no option to perform relative scaling.
AbstractPlotting.scatter!
— Methodscatter(positions)
scatter(x, y)
scatter(x, y, z)
Plots a marker for each element in (x, y, z)
, (x, y)
, or positions
.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.scatter!, T} where T
are:
AbstractPlotting.scatter
— Methodscatter(positions)
scatter(x, y)
scatter(x, y, z)
Plots a marker for each element in (x, y, z)
, (x, y)
, or positions
.
Attributes
Available attributes and their defaults for Scatter{T} where T
are:
ambient Float32[0.55, 0.55, 0.55]
color :gray65
colormap :viridis
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
distancefield "nothing"
glowcolor RGBA{N0f8}(0.0,0.0,0.0,0.0)
glowwidth 0.0
lightposition :eyeposition
linewidth 1
marker Circle{T} where T
marker_offset AbstractPlotting.Automatic()
markersize 10
markerspace Pixel
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
rotations Billboard()
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
strokecolor :black
strokewidth 1.0
transform_marker false
transparency false
uv_offset_width Float32[0.0, 0.0, 0.0, 0.0]
visible true
AbstractPlotting.scatterlines!
— Methodscatterlines(xs, ys, [zs]; kwargs...)
Plots scatter
markers and lines
between them.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.scatterlines!, T} where T
are:
AbstractPlotting.scatterlines
— Methodscatterlines(xs, ys, [zs]; kwargs...)
Plots scatter
markers and lines
between them.
Attributes
Available attributes and their defaults for ScatterLines{T} where T
are:
color :black
colormap :viridis
colorrange AbstractPlotting.Automatic()
linestyle "nothing"
linewidth 1.0
marker Circle{T} where T
markercolor :gray65
markercolormap :viridis
markercolorrange AbstractPlotting.Automatic()
markersize 10
strokecolor :black
strokewidth 1.0
AbstractPlotting.select_line
— Methodselect_line(scene; kwargs...) -> line
Interactively select a line (typically an arrow) on a 2D scene
by clicking the left mouse button, dragging and then un-clicking. Return an observable whose value corresponds to the selected line on the scene. In addition the function plots the line on the scene as the user clicks and moves the mouse around. When the button is not clicked any more, the plotted line disappears.
The value of the returned line is updated only when the user un-clicks and only if the selected line has non-zero length.
The kwargs...
are propagated into lines!
which plots the selected line.
AbstractPlotting.select_point
— Methodselect_point(scene; kwargs...) -> point
Interactively select a point on a 2D scene
by clicking the left mouse button, dragging and then un-clicking. Return an observable whose value corresponds to the selected point on the scene. In addition the function plots the point on the scene as the user clicks and moves the mouse around. When the button is not clicked any more, the plotted point disappears.
The value of the returned point is updated only when the user un-clicks.
The kwargs...
are propagated into scatter!
which plots the selected point.
AbstractPlotting.select_rectangle
— Methodselect_rectangle(scene; kwargs...) -> rect
Interactively select a rectangle on a 2D scene
by clicking the left mouse button, dragging and then un-clicking. The function returns an observable rect
whose value corresponds to the selected rectangle on the scene. In addition the function plots the selected rectangle on the scene as the user clicks and moves the mouse around. When the button is not clicked any more, the plotted rectangle disappears.
The value of the returned observable is updated only when the user un-clicks (i.e. when the final value of the rectangle has been decided) and only if the rectangle has area > 0.
The kwargs...
are propagated into lines!
which plots the selected rectangle.
AbstractPlotting.series!
— MethodSeries - ?
TODO add function signatures TODO add description
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.series!, T} where T
are:
AbstractPlotting.series
— MethodSeries - ?
TODO add function signatures TODO add description
Attributes
Available attributes and their defaults for Series{T} where T
are:
seriescolors :Set1
seriestype :lines
AbstractPlotting.set_theme!
— Functionset_theme(theme; kwargs...)
Set the global default theme to theme
and add / override any attributes given as keyword arguments.
AbstractPlotting.showgradients
— Methodshowgradients(
cgrads::AbstractVector{Symbol};
h = 0.0, offset = 0.2, textsize = 0.7,
resolution = (800, length(cgrads) * 84)
)::Scene
Plots the given colour gradients arranged as horizontal colourbars. If you change the offsets or the font size, you may need to change the resolution.
AbstractPlotting.spy!
— Methodspy(x::Range, y::Range, z::AbstractSparseArray)
Visualizes big sparse matrices. Usage:
N = 200_000
x = sprand(Float64, N, N, (3(10^6)) / (N*N));
spy(x)
# or if you want to specify the range of x and y:
spy(0..1, 0..1, x)
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.spy!, T} where T
are:
AbstractPlotting.spy
— Methodspy(x::Range, y::Range, z::AbstractSparseArray)
Visualizes big sparse matrices. Usage:
N = 200_000
x = sprand(Float64, N, N, (3(10^6)) / (N*N));
spy(x)
# or if you want to specify the range of x and y:
spy(0..1, 0..1, x)
Attributes
Available attributes and their defaults for Spy{T} where T
are:
colormap :viridis
colorrange AbstractPlotting.Automatic()
framecolor :black
framesize 1
marker AbstractPlotting.Automatic()
markersize AbstractPlotting.Automatic()
AbstractPlotting.stem!
— Methodstem(xs, ys, [zs]; kwargs...)
Plots markers at the given positions extending from offset
along stem lines.
offset
can be a number, in which case it sets y for 2D, and z for 3D stems. It can be a Point2 for 2D plots, as well as a Point3 for 3D plots. It can also be an iterable of any of these at the same length as xs, ys, zs.
The conversion trait of stem is PointBased
.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.stem!, T} where T
are:
AbstractPlotting.stem
— Methodstem(xs, ys, [zs]; kwargs...)
Plots markers at the given positions extending from offset
along stem lines.
offset
can be a number, in which case it sets y for 2D, and z for 3D stems. It can be a Point2 for 2D plots, as well as a Point3 for 3D plots. It can also be an iterable of any of these at the same length as xs, ys, zs.
The conversion trait of stem is PointBased
.
Attributes
Available attributes and their defaults for Stem{T} where T
are:
color :gray65
colormap :viridis
colorrange AbstractPlotting.Automatic()
marker :circle
markersize 10
offset 0
stemcolor :black
stemcolormap :viridis
stemcolorrange AbstractPlotting.Automatic()
stemlinestyle "nothing"
stemwidth 1
strokecolor :black
strokewidth 1
trunkcolor :black
trunkcolormap :viridis
trunkcolorrange AbstractPlotting.Automatic()
trunklinestyle "nothing"
trunkwidth 1
visible true
AbstractPlotting.step!
— Methodstep!(s::Stepper)
steps through a Makie.Stepper
and outputs a file with filename filename-step.jpg
. This is useful for generating progressive plot examples.
AbstractPlotting.streamplot!
— Methodstreamplot(f::function, xinterval, yinterval; kwargs...)
f must either accept f(::Point)
or f(x::Number, y::Number)
. f must return a Point2.
Example:
v(x::Point2{T}) where T = Point2f0(x[2], 4*x[1])
streamplot(v, -2..2, -2..2)
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.streamplot!, T} where T
are:
Implementation
See the function AbstractPlotting.streamplot_impl
for implementation details.
AbstractPlotting.streamplot
— Methodstreamplot(f::function, xinterval, yinterval; kwargs...)
f must either accept f(::Point)
or f(x::Number, y::Number)
. f must return a Point2.
Example:
v(x::Point2{T}) where T = Point2f0(x[2], 4*x[1])
streamplot(v, -2..2, -2..2)
Attributes
Available attributes and their defaults for StreamPlot{T} where T
are:
ambient Float32[0.55, 0.55, 0.55]
arrow_size 0.03
color :black
colormap :viridis
colorrange AbstractPlotting.Automatic()
density 1.0
diffuse Float32[0.4, 0.4, 0.4]
gridsize (32, 32, 32)
lightposition :eyeposition
linestyle "nothing"
linewidth 1.0
maxsteps 500
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
stepsize 0.01
transparency false
visible true
Implementation
See the function AbstractPlotting.streamplot_impl
for implementation details.
AbstractPlotting.surface!
— Methodsurface(x, y, z)
Plots a surface, where (x, y)
define a grid whose heights are the entries in z
. x
and y
may be Vectors
which define a regular grid, or Matrices
which define an irregular grid.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.surface!, T} where T
are:
AbstractPlotting.surface
— Methodsurface(x, y, z)
Plots a surface, where (x, y)
define a grid whose heights are the entries in z
. x
and y
may be Vectors
which define a regular grid, or Matrices
which define an irregular grid.
Attributes
Available attributes and their defaults for Surface{T} where T
are:
ambient Float32[0.55, 0.55, 0.55]
color "nothing"
colormap :viridis
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
highclip "nothing"
invert_normals false
lightposition :eyeposition
linewidth 1
lowclip "nothing"
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
shading true
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.text!
— Methodtext(string)
Plots a text.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.text!, T} where T
are:
AbstractPlotting.text
— Methodtext(string)
Plots a text.
Attributes
Available attributes and their defaults for AbstractPlotting.Text{T} where T
are:
_glyphlayout "nothing"
align (:left, :bottom)
ambient Float32[0.55, 0.55, 0.55]
color :black
diffuse Float32[0.4, 0.4, 0.4]
font "Dejavu Sans"
justification AbstractPlotting.Automatic()
lightposition :eyeposition
lineheight 1.0
linewidth 1
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
position Float32[0.0, 0.0]
rotation 0.0
shininess 32.0f0
space :screen
specular Float32[0.2, 0.2, 0.2]
ssao false
strokecolor (:black, 0.0)
strokewidth 0
textsize 20
transparency false
visible true
AbstractPlotting.timeseries!
— Methodtimeseries(x::Node{{Union{Number, Point2}}})
Plots a sampled signal. Usage:
signal = Node(1.0)
scene = timeseries(signal)
display(scene)
# @async is optional, but helps to continue evaluating more code
@async while isopen(scene)
# aquire data from e.g. a sensor:
data = rand()
# update the signal
signal[] = data
# sleep/ wait for new data/ whatever...
# It's important to yield here though, otherwise nothing will be rendered
sleep(1/30)
end
AbstractPlotting.timeseries
— Methodtimeseries(x::Node{{Union{Number, Point2}}})
Plots a sampled signal. Usage:
signal = Node(1.0)
scene = timeseries(signal)
display(scene)
# @async is optional, but helps to continue evaluating more code
@async while isopen(scene)
# aquire data from e.g. a sensor:
data = rand()
# update the signal
signal[] = data
# sleep/ wait for new data/ whatever...
# It's important to yield here though, otherwise nothing will be rendered
sleep(1/30)
end
AbstractPlotting.title
— Methodtitle(
[scene=current_scene(), ], string;
align = (:center, :bottom), textsize = 30, parent = Scene(), formatter = string, kw...
)
Add a title with content string
to scene
. Pass a Function
to the formatter
kwarg if the value passed to string
isn't actually a String.
AbstractPlotting.to_color
— Methodto_color(color)
Converts a color
symbol (e.g. :blue
) to a color RGBA.
AbstractPlotting.to_colormap
— Methodto_colormap(cm[, N = 20])
Converts a colormap cm
symbol (e.g. :Spectral
) to a colormap RGB array, where N
specifies the number of color points.
AbstractPlotting.translate!
— Methodtranslate!(scene::Transformable, xyz::VecTypes)
translate!(scene::Transformable, xyz...)
Apply an absolute translation to the Scene, translating it to x, y, z
.
AbstractPlotting.translate!
— Methodtranslate!(Accum, scene::Transformable, xyz...)
Translate the scene relative to its current position.
AbstractPlotting.translate_cam!
— Methodtranslate_cam!(scene::Scene. translation::VecTypes)
Translate the camera to the given coordinates.
AbstractPlotting.update!
— Method`update!(p::Scene)`
Updates a Scene
and all its children. Update will perform the following operations for every scene:
if !scene.raw[]
scene.update_limits[] && update_limits!(scene)
scene.scale_plot[] && scale_scene!(scene)
scene.center[] && center!(scene)
end
AbstractPlotting.update_cam!
— Functionupdate_cam!(scene::Scene, eyeposition, lookat, up = Vec3f0(0, 0, 1))
Updates the camera's controls to point to the specified location.
AbstractPlotting.update_cam!
— Methodupdate_cam!(scene::SceneLike, area)
Updates the camera for the given scene
to cover the given area
in 2d.
AbstractPlotting.update_cam!
— Methodupdate_cam!(scene::SceneLike)
Updates the camera for the given scene
to cover the limits of the Scene
. Useful when using the Node
pipeline.
AbstractPlotting.update_limits!
— Functionupdate_limits!(scene::Scene, new_limits::Rect, padding = Vec3f0(0))
This function updates the limits of the given Scene
according to the given Rect.
A Rect
is a generalization of a rectangle to n dimensions. It contains two vectors. The first vector defines the origin; the second defines the displacement of the vertices from the origin. This second vector can be thought of in two dimensions as a vector of width (x-axis) and height (y-axis), and in three dimensions as a vector of the width (x-axis), breadth (y-axis), and height (z-axis).
Such a Rect
can be constructed using the FRect
or FRect3D
functions that are exported by AbstractPlotting.jl
. See their documentation for more information.
AbstractPlotting.update_limits!
— Methodupdate_limits!(scene::Scene, limits::Union{Automatic, Rect} = scene.limits[], padding = scene.padding[])
This function updates the limits of the Scene
passed to it based on its data. If an actual limit is set by the theme or its attributes (scene.limits !== automatic), it will not update the limits. Call update_limits!(scene, automatic) for that.
AbstractPlotting.volume!
— Methodvolume(volume_data)
Plots a volume. Available algorithms are:
:iso
=> IsoValue:absorption
=> Absorption:mip
=> MaximumIntensityProjection:absorptionrgba
=> AbsorptionRGBA:additive
=> AdditiveRGBA:indexedabsorption
=> IndexedAbsorptionRGBA
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.volume!, T} where T
are:
AbstractPlotting.volume
— Methodvolume(volume_data)
Plots a volume. Available algorithms are:
:iso
=> IsoValue:absorption
=> Absorption:mip
=> MaximumIntensityProjection:absorptionrgba
=> AbsorptionRGBA:additive
=> AdditiveRGBA:indexedabsorption
=> IndexedAbsorptionRGBA
Attributes
Available attributes and their defaults for Volume{T} where T
are:
algorithm :mip
ambient Float32[0.55, 0.55, 0.55]
color "nothing"
colormap :viridis
colorrange (0, 1)
diffuse Float32[0.4, 0.4, 0.4]
isorange 0.05
isovalue 0.5
lightposition :eyeposition
linewidth 1
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.volumeslices!
— MethodVolumeSlices
TODO add function signatures TODO add descripton
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.volumeslices!, T} where T
are:
AbstractPlotting.volumeslices
— MethodVolumeSlices
TODO add function signatures TODO add descripton
Attributes
Available attributes and their defaults for VolumeSlices{T} where T
are:
alpha 0.1
colormap :viridis
colorrange "nothing"
contour Attributes with 0 entries
heatmap Attributes with 0 entries
AbstractPlotting.wireframe!
— Methodwireframe(x, y, z)
wireframe(positions)
wireframe(mesh)
Draws a wireframe, either interpreted as a surface or as a mesh.
Attributes
Available attributes and their defaults for Combined{AbstractPlotting.wireframe!, T} where T
are:
AbstractPlotting.wireframe
— Methodwireframe(x, y, z)
wireframe(positions)
wireframe(mesh)
Draws a wireframe, either interpreted as a surface or as a mesh.
Attributes
Available attributes and their defaults for Wireframe{T} where T
are:
ambient Float32[0.55, 0.55, 0.55]
color :black
colormap :viridis
colorrange AbstractPlotting.Automatic()
diffuse Float32[0.4, 0.4, 0.4]
lightposition :eyeposition
linestyle "nothing"
linewidth 1.0
nan_color RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.0f0)
overdraw false
shininess 32.0f0
specular Float32[0.2, 0.2, 0.2]
ssao false
transparency false
visible true
AbstractPlotting.with_theme
— Functionwith_theme(f, theme = Theme(); kwargs...)
Calls f
with theme
temporarily activated. Attributes in theme
can be overridden or extended with kwargs
. The previous theme is always restored afterwards, no matter if f
succeeds or fails.
Example:
my_theme = Theme(resolution = (500, 500), color = :red)
with_theme(my_theme, color = :blue, linestyle = :dashed) do
scatter(randn(100, 2))
end
AbstractPlotting.xlabel!
— Methodxlabel!([scene,] xlabel)
Set the x-axis label for the given Scene. Defaults to using the current Scene.
AbstractPlotting.xlims!
— Methodxlims!(limits::Real...)
xlims!(limits::NTuple{2, Real})
xlims!(scene, limits::Real...)
xlims!(scene, limits::NTuple{2, Real})
Set the x-limits for the given Scene (defaults to current Scene).
AbstractPlotting.xticklabels
— Methodxticklabels(scene)
Returns the all the x-axis tick labels. See also ticklabels
.
AbstractPlotting.xtickrange
— Methodxtickrange(scene)
Returns the tick range along the x-axis. See also tickranges
.
AbstractPlotting.xtickrotation!
— Methodxtickrotation!([scene,] xangle)
Set the rotation of tick labels along the x-axis. See also tickrotations!
.
AbstractPlotting.xtickrotation
— Methodxtickrotation(scene)
Returns the rotation of tick labels along the x-axis. See also tickrotations
AbstractPlotting.xticks!
— Functionxticks!([scene,]; xtickrange=xtickrange(scene), xticklabels=xticklabel(scene))
Set the tick labels and range along the x-axes. See also ticks!
.
AbstractPlotting.ylabel!
— Methodylabel!([scene,] ylabel)
Set the y-axis label for the given Scene. Defaults to using the current Scene.
AbstractPlotting.ylims!
— Methodylims!(limits::Real...)
ylims!(limits::NTuple{2, Real})
ylims!(scene, limits::Real...)
ylims!(scene, limits::NTuple{2, Real})
Set the y-limits for the given Scene (defaults to current Scene).
AbstractPlotting.yticklabels
— Methodyticklabels(scene)
Returns the all the y-axis tick labels. See also ticklabels
.
AbstractPlotting.ytickrange
— Methodytickrange(scene)
Returns the tick range along the y-axis. See also tickranges
.
AbstractPlotting.ytickrotation!
— Methodytickrotation!([scene,] yangle)
Set the rotation of tick labels along the y-axis. See also tickrotations!
.
AbstractPlotting.ytickrotation
— Methodytickrotation(scene)
Returns the rotation of tick labels along the y-axis. See also tickrotations
AbstractPlotting.yticks!
— Functionyticks!([scene,]; ytickrange=ytickrange(scene), yticklabels=yticklabel(scene))
Set the tick labels and range along all the y-axis. See also ticks!
.
AbstractPlotting.zlabel!
— Methodzlabel!([scene,] zlabel)
Set the z-axis label for the given Scene. Defaults to using the current Scene.
The Scene must have an Axis3D. If not, then this function will error.
AbstractPlotting.zlims!
— Methodzlims!(limits::Real...)
zlims!(limits::NTuple{2, Real})
zlims!(scene, limits::Real...)
zlims!(scene, limits::NTuple{2, Real})
Set the z-limits for the given Scene (defaults to current Scene).
AbstractPlotting.zoom!
— Methodzoom!(scene, point, zoom_step, shift_lookat::Bool)
Zooms the camera of scene
in towards point
by a factor of zoom_step
. A positive zoom_step
zooms in while a negative zoom_step
zooms out.
AbstractPlotting.zticklabels
— Methodzticklabels(scene)
Returns the all the z-axis tick labels. See also ticklabels
.
AbstractPlotting.ztickrange
— Methodztickrange(scene)
Returns the tick range along the z-axis. See also tickranges
.
AbstractPlotting.ztickrotation!
— Methodztickrotation!([scene,] zangle)
Set the rotation of tick labels along the z-axis. See also tickrotations!
.
AbstractPlotting.ztickrotation
— Methodztickrotation(scene)
Returns the rotation of tick labels along the z-axis. See also tickrotations
AbstractPlotting.zticks!
— Functionzticks!([scene,]; ztickranges=ztickrange(scene), zticklabels=zticklabel(scene))
Set the tick labels and range along all z-axis. See also ticks!
.
FileIO.save
— MethodFileIO.save(filename, scene; resolution = size(scene), pt_per_unit = 1.0, px_per_unit = 1.0)
Save a Scene
with the specified filename and format.
Supported Formats
GLMakie
:.png
,.jpeg
, and.bmp
CairoMakie
:.svg
,.pdf
,.png
, and.jpeg
WGLMakie
:.png
Supported Keyword Arguments
All Backends
resolution
:(width::Int, height::Int)
of the scene in dimensionless units (equivalent topx
for GLMakie and WGLMakie).
CairoMakie
pt_per_unit
: The size of one scene unit inpt
when exporting to a vector format.px_per_unit
: The size of one scene unit inpx
when exporting to a bitmap format. This provides a mechanism to export the same scene with higher or lower resolution.
FileIO.save
— Methodsave(path::String, io::VideoStream; framerate = 24, compression = 20)
Flushes the video stream and converts the file to the extension found in path
, which can be one of the following:
.mkv
(the default, doesn't need to convert).mp4
(good for Web, most supported format).webm
(smallest file size).gif
(largest file size for the same quality)
.mp4
and .mk4
are marginally bigger and .gif
s are up to 6 times bigger with the same quality!
The compression
argument controls the compression ratio; 51
is the highest compression, and 0
is the lowest (lossless).
See the docs of VideoStream
for how to create a VideoStream. If you want a simpler interface, consider using record
.
Observables.on
— Methodon(f, c::Camera, nodes::Node...)
When mapping over nodes for the camera, we store them in the steering_node
vector, to make it easier to disconnect the camera steering signals later!
AbstractPlotting.@extract
— Macrousage @exctract scene (a, b, c, d)
AbstractPlotting.@extractvalue
— Macrousage @extractvalue scene (a, b, c, d) will become:
begin
a = to_value(scene[:a])
b = to_value(scene[:b])
c = to_value(scene[:c])
(a, b, c)
end
AbstractPlotting.@get_attribute
— Macro@get_attribute scene (a, b, c, d)
This will extract attribute a
, b
, c
, d
from scene
and apply the correct attribute conversions + will extract the value if it's a signal. It will make those attributes available as variables and return them as a tuple. So the above is equal to: will become:
begin
a = get_attribute(scene, :a)
b = get_attribute(scene, :b)
c = get_attribute(scene, :c)
(a, b, c)
end
AbstractPlotting.@lift
— MacroReplaces an expression with lift(argtuple -> expression, args...), where args are all expressions inside the main one that begin with $.
Example:
x = Node(rand(100)) y = Node(rand(100))
before
z = lift((x, y) -> x .+ y, x, y)
after
z = @lift(x .+ y)
You can also use parentheses around an expression if that expression evaluates to a node.
nt = (x = Node(1), y = Node(2))
@lift($(nt.x) + $(nt.y))
AbstractPlotting.@recipe
— MacroPlot Recipes in AbstractPlotting
There's two types of recipes. Type recipes define a simple mapping from a user defined type to an existing plot type. Full recipes can customize the theme and define a custom plotting function.
Type recipes
Type recipe are really simple and just overload the argument conversion pipeline. This can be done for all plot types or for a subset of plot types:
# All plot types
convert_arguments(P::Type{<:AbstractPlot}, x::MyType) = convert_arguments(P, rand(10, 10))
# Only for scatter plots
convert_arguments(P::Type{<:Scatter}, x::MyType) = convert_arguments(P, rand(10, 10))
Optionally you may define the default plot type so that plot(x::MyType)
will use this:
plottype(::MyType) = Surface
Full recipes with the @recipe
macro
A full recipe for MyPlot
comes in two parts. First is the plot type name, arguments and theme definition which are defined using the @recipe
macro. Second is a custom plot!
for MyPlot
, implemented in terms of the atomic plotting functions.
We use an example to show how this works:
# arguments (x, y, z) && theme are optional
@recipe(MyPlot, x, y, z) do scene
Attributes(
plot_color => :red
)
end
This macro expands to several things. Firstly a type definition:
const MyPlot{ArgTypes} = Combined{myplot, ArgTypes}
The type parameter of Combined
contains the function instead of e.g. a symbol. This way the mapping from MyPlot
to myplot
is safer and simpler. (The downside is we always need a function myplot
- TODO: is this a problem?)
The following signatures are defined to make MyPlot
nice to use:
myplot(args...; kw_args...) = ...
myplot!(scene, args...; kw_args...) = ...
myplot(kw_args::Dict, args...) = ...
myplot!(scene, kw_args::Dict, args...) = ...
#etc (not 100% settled what signatures there will be)
A specialization of argument_names
is emitted if you have an argument list (x,y,z)
provided to the recipe macro:
argument_names(::Type{<: MyPlot}) = (:x, :y, :z)
This is optional but it will allow the use of plot_object[:x]
to fetch the first argument from the call plot_object = myplot(rand(10), rand(10), rand(10))
, for example. Alternatively you can always fetch the i
th argument using plot_object[i]
, and if you leave out the (x,y,z)
, the default version of argument_names
will provide plot_object[:arg1]
etc.
The theme given in the body of the @recipe
invocation is inserted into a specialization of default_theme
which inserts the theme into any scene that plots MyPlot
:
function default_theme(scene, ::MyPlot)
Attributes(
plot_color => :red
)
end
As the second part of defining MyPlot
, you should implement the actual plotting of the MyPlot
object by specializing plot!
:
function plot!(plot::MyPlot)
# normal plotting code, building on any previously defined recipes
# or atomic plotting operations, and adding to the combined `plot`:
lines!(plot, rand(10), color = plot[:plot_color])
plot!(plot, plot[:x], plot[:y])
plot
end
It's possible to add specializations here, depending on the argument types supplied to myplot
. For example, to specialize the behavior of myplot(a)
when a
is a 3D array of floating point numbers:
const MyVolume = MyPlot{Tuple{<:AbstractArray{<: AbstractFloat, 3}}}
argument_names(::Type{<: MyVolume}) = (:volume,) # again, optional
function plot!(plot::MyVolume)
# plot a volume with a colormap going from fully transparent to plot_color
volume!(plot, plot[:volume], colormap = :transparent => plot[:plot_color])
plot
end
The docstring given to the recipe will be transferred to the functions it generates.
Unexported
AbstractPlotting.automatic
— ConstantSingleton instance to indicate that an attribute will get calculated automatically
AbstractPlotting.current_backend
— ConstantCurrent backend
AbstractPlotting.AbstractPattern
— TypeAbstractPattern{T} <: AbstractArray{T, 2}
AbstractPatterns
are image-like array types which can be used to color plottable objects. There are currently two subtypes: LinePattern
and ImagePattern
. Any abstract pattern must implement the to_image(pat)
function, which must return a Matrix{<: AbstractRGB}
.
AbstractPlotting.Automatic
— TypeType to indicate that an attribute will get calculated automatically
AbstractPlotting.ColorSampler
— TypeA colorsampler maps numnber values from a certain range to values of a colormap
x = ColorSampler(colormap, (0.0, 1.0))
x[0.5] # returns color at half point of colormap
AbstractPlotting.DeviceIndependentPixel
— Typehttps://en.wikipedia.org/wiki/Device-independent_pixel A device-independent pixel (also: density-independent pixel, dip, dp) is a physical unit of measurement based on a coordinate system held by a computer and represents an abstraction of a pixel for use by an application that an underlying system then converts to physical pixels.
AbstractPlotting.FastPixel
— TypeFastPixel()
Use
scatter(..., marker=FastPixel())
For significant faster plotting times for large amount of points. Note, that this will draw markers always as 1 pixel.
AbstractPlotting.FolderStepper
— TypeStepper(scene, path; format = :jpg)
Creates a Stepper for generating progressive plot examples.
Each "step" is saved as a separate file in the folder pointed to by path
, and the format is customizable by format
, which can be any output type your backend supports.
AbstractPlotting.Glyphlayout
— TypeGlyphlayout
Stores information about the glyphs in a string that had a layout calculated for them. origins
are the character origins relative to the layout's [0,0] point (the alignment) and rotation anchor). bboxes
are the glyph bounding boxes relative to the glyphs' own origins. hadvances
are the horizontal advance values, those are mostly needed for interactive purposes, for example to display a cursor at the right offset from a space character.
AbstractPlotting.LinePattern
— MethodLinePattern([; kwargs...])
Creates a LinePattern
for the given keyword arguments:
direction
: The direction of the line.width
: The width of the linetilesize
: The size of the image on which the line is drawn. This should be
compatible with the direction.
shift
: Sets the starting point for the line.linecolor
: The color with which the line is replaced.background_color
:: The background color.
Multiple direction
s, width
s and shift
s can also be given to create more complex patterns, e.g. a cross-hatching pattern.
AbstractPlotting.Millimeter
— TypeMillimeter on screen. This unit respects the dimension and pixel density of the screen to represent millimeters on the screen. This is the must use unit for layouting, that needs to look the same on all kind of screens. Similar as with the Pixel
unit, a camera can change the actually displayed dimensions of any object using the millimeter unit.
AbstractPlotting.ObservableAttributes
— TypeMain structure for holding attributes in e.g. plots!
AbstractPlotting.OnFieldUpdate
— Typeattributes.attribute returns an observable. Since we don't actually convert all values to Observables anymore, we'll need to create new Observables on getproperty. With OnFieldUpdate, we can do that lazily, store them in listeners(onchange(obs))
, and only create a new one for fields that aren't in listeners yet.
AbstractPlotting.Transformable
— Typeabstract type Transformable
This is a bit of a weird name, but all scenes and plots are transformable, so that's what they all have in common. This might be better expressed as traits.
AbstractPlotting.Plot
— MethodReturns the Combined type that represents the signature of args
.
AbstractPlotting._group_polys
— Method_group_polys(points, ids)
Given a vector of polygon vertices, and one vector of group indices, which are assumed to be returned from the isoband algorithm, return a vector of groups, where each group has one outer polygon and zero or more inner polygons which are holes in the outer polygon. It is possible that one group has multiple outer polygons with multiple holes each.
AbstractPlotting.apply_convert!
— Methodapply for return type (args...,)
AbstractPlotting.apply_convert!
— Methodapply for return type PlotSpec
AbstractPlotting.apply_scaling
— Methodapply_scaling(value::Number, scaling::Scaling)
Scales a number to the range 0..1.
AbstractPlotting.apply_transform
— Methodapply_transform(f, data)
Apply the data transform func to the data
AbstractPlotting.argument_names
— MethodEach argument can be named for a certain plot type P
. Falls back to arg1
, arg2
, etc.
AbstractPlotting.atomic_limits
— MethodData limits calculate a minimal boundingbox from the data points in a plot. This doesn't include any transformations, markers etc.
AbstractPlotting.attributes_from
— Methodattributes_from(PlotType, plot)
Gets the attributes from plot, that are valid for PlotType
AbstractPlotting.available_marker_symbols
— Methodavailable_marker_symbols()
Displays all available marker symbols.
AbstractPlotting.calculated_attributes!
— Method`calculated_attributes!(trait::Type{<: AbstractPlot}, plot)`
trait version of calculated_attributes
AbstractPlotting.calculated_attributes!
— Method`calculated_attributes!(plot::AbstractPlot)`
Fill in values that can only be calculated when we have all other attributes filled
AbstractPlotting.cam3d_turntable!
— Methodcam3d_turntable!(scene; kw_args...)
Creates a 3D camera for scene
, which rotates around the plot's axis.
AbstractPlotting.check_line_pattern
— MethodChecks if the linestyle format provided as a string contains only dashes and dots
AbstractPlotting.close2square
— MethodReturns (N1, N2) with N1 x N2 == n
. N2 might become 1
AbstractPlotting.colorbuffer
— Functioncolorbuffer(scene, format::ImageStorageFormat = JuliaNative)
colorbuffer(screen, format::ImageStorageFormat = JuliaNative)
Returns the content of the given scene or screen rasterised to a Matrix of Colors. The return type is backend-dependent, but will be some form of RGB or RGBA.
format = JuliaNative
: Returns a buffer in the format of standard julia images (dims permuted and one reversed)format = GLNative
: Returns a more efficient format buffer for GLMakie which can be directly used in FFMPEG without conversion
AbstractPlotting.current_scene
— MethodReturns the current active scene (the last scene that got created)
AbstractPlotting.default_plot_signatures
— Method default_plot_signatures(funcname, funcname!, PlotType)
Creates all the different overloads for funcname
that need to be supported for the plotting frontend! Since we add all these signatures to different functions, we make it reusable with this function. The Core.@__doc__
macro transfers the docstring given to the Recipe into the functions.
AbstractPlotting.elconvert
— MethodConverts the elemen array type to T1
without making a copy if the element type matches
AbstractPlotting.extract_scene_attributes!
— Methodextract_scene_attributes!(attributes)
removes all scene attributes from attributes
and returns them in a new Attribute dict.
AbstractPlotting.find_font_for_char
— Methodfind_font_for_char(c::Char, font::NativeFont)
Finds the best font for a character from a list of fallback fonts, that get chosen if font
can't represent char c
AbstractPlotting.find_node_expressions
— MethodReturns a set of all sub-expressions in an expression that look like some_expression
AbstractPlotting.flatten_combined
— FunctionFlattens all the combined plots and returns a Vector of Atomic plots
AbstractPlotting.from_dict
— Methodfrom_dict(::Type{T}, dict)
Creates the type T
from the fields in dict. Automatically converts to the correct node types.
AbstractPlotting.frustum
— MethodCreate view frustum
Parameters
----------
left : float
Left coordinate of the field of view.
right : float
Left coordinate of the field of view.
bottom : float
Bottom coordinate of the field of view.
top : float
Top coordinate of the field of view.
znear : float
Near coordinate of the field of view.
zfar : float
Far coordinate of the field of view.
Returns
-------
M : array
View frustum matrix (4x4).
AbstractPlotting.get_attribute
— Methodget_attribute(dict::ObservableAttributes, key::Key)
Gets the attribute at key
, converts it and extracts the value
AbstractPlotting.get_lifted_attribute
— Methodget_attribute(dict::ObservableAttributes, key::Key)
Gets the attribute at key
as a converted signal
AbstractPlotting.get_value
— Methodget_value(attributes::ObservableAttributes, field::Symbol)
Gets the value for field
. The values are looked up in the following order: 1) user given at creation time 2) theme given 3) global defaults
AbstractPlotting.getscreen
— Methodgetscreen(scene::Scene)
Gets the current screen a scene is associated with. Returns nothing if not yet displayed on a screen.
AbstractPlotting.glyph_positions
— Methodglyph_positions(str::AbstractString, font_per_char, fontscale_px, halign, valign, lineheight_factor, justification, rotation)
Calculate the positions for each glyph in a string given a certain font, font size, alignment, etc. This layout in text coordinates, relative to the anchor point [0,0] can then be translated and rotated to wherever it is needed in the plot.
AbstractPlotting.interpolated_getindex
— Methodinterpolated_getindex(cmap::AbstractArray, value::AbstractFloat, norm = (0.0, 1.0))
Like getindex, but accepts values between 0..1 and interpolates those to the full range. You can use norm
, to change the range of 0..1 to whatever you want.
AbstractPlotting.interpolated_getindex
— Methodinterpolated_getindex(cmap::AbstractArray, value::AbstractFloat)
Like getindex, but accepts values between 0..1 for value
and interpolates those to the full range of cmap
.
AbstractPlotting.layout_text
— Methodlayout_text(
string::AbstractString, textsize::Union{AbstractVector, Number},
font, align, rotation, model, justification, lineheight
)
Compute a Glyphlayout for a string
given textsize, font, align, rotation, model, justification, and lineheight.
AbstractPlotting.lookat
— Methodview = lookat(eyeposition, lookat, up)
creates a view matrix with the eye located at eyeposition
and looking at position lookat
, with the top of the window corresponding to the direction up
. Only the component of up
that is perpendicular to the vector pointing from eyeposition
to lookat
will be used. All inputs must be supplied as 3-vectors.
AbstractPlotting.mouse_in_scene
— Methodmouse_in_scene(scene::Scene)
returns the mouseposition relative to scene
AbstractPlotting.peaks
— Functionpeaks([n=49])
Return a nonlinear function on a grid. Useful for test cases.
AbstractPlotting.perspectiveprojection
— Methodproj = perspectiveprojection([T], fovy, aspect, znear, zfar)
defines a projection matrix with a given angular field-of-view fovy
along the y-axis (measured in degrees), the specified aspect
ratio, and near and far clipping planes znear
, zfar
. Optionally specify the element type T
of the matrix.
AbstractPlotting.perspectiveprojection
— Methodproj = perspectiveprojection([T], rect, fov, near, far)
defines the projection ratio in terms of the rectangular view size rect
rather than the aspect ratio.
AbstractPlotting.plots_from_camera
— MethodFetches all plots sharing the same camera
AbstractPlotting.plottype
— Method`plottype(plot_args...)`
Any custom argument combination that has a preferred way to be plotted should overload this. e.g.:
# make plot(rand(5, 5, 5)) plot as a volume
plottype(x::Array{<: AbstractFloat, 3}) = Volume
AbstractPlotting.plottype
— Methodplottype(P1::Type{<: Combined{T1}}, P2::Type{<: Combined{T2}})
Chooses the more concrete plot type ```example function convert_arguments(P::PlotFunc, args...) ptype = plottype(P, Lines) ... end
AbstractPlotting.primary_resolution
— FunctionReturns the resolution of the primary monitor. If the primary monitor can't be accessed, returns (1920, 1080) (full hd)
AbstractPlotting.print_rec
— Functionprint_rec(io::IO, dict, indent::Int = 1[; extended = false])
Traverses a dictionary dict
and recursively print out its keys and values in a nicely-indented format.
Use the optional extended = true
keyword argument to see more details.
AbstractPlotting.raw_boundingbox
— MethodCalculates the exact boundingbox of a Scene/Plot, without considering any transformation
AbstractPlotting.reasonable_resolution
— MethodReturns a reasonable resolution for the main monitor. (right now just half the resolution of the main monitor)
AbstractPlotting.replace_node_expressions!
— MethodReplaces every subexpression that looks like a node expression with a substitute symbol stored in exprdict
.
AbstractPlotting.resample
— Methodresample(A::AbstractVector, len::Integer)
Resample a vector with linear interpolation to have length len
AbstractPlotting.resampled_colors
— Methodresampled_colors(attributes::Attributes, levels::Integer)
Resample the color attribute from attributes
. Resamples :colormap
if present, or repeats :color
.
AbstractPlotting.rotatedrect
— MethodCalculate an approximation of a tight rectangle around a 2D rectangle rotated by angle
radians. This is not perfect but works well enough. Check an A vs X to see the difference.
AbstractPlotting.safe_off
— MethodObservables.off but without throwing an error
AbstractPlotting.screen_relative
— MethodNormalizes mouse position relative to the screen rectangle
AbstractPlotting.sdistancefield
— Methodsdistancefield(img, downsample, pad)
Calculates a distance fields, that is downsampled downsample
time, with a padding applied of pad
. The padding is in units after downscaling!
AbstractPlotting.setlims!
— Functionsetlims!(scene::Scene, min_max::NTuple{2, Real}, dim=1)
Sets the limits of the scene for dim=1.
AbstractPlotting.showlibrary
— Methodshowlibrary(lib::Symbol)::Scene
Shows all colour gradients in the given library. Returns a Scene with these colour gradients arranged as horizontal colourbars.
AbstractPlotting.streamplot_impl
— Methodstreamplot_impl(CallType, f, limits::Rect{N, T}, resolutionND, stepsize)
Code adapted from an example implementation by Moritz Schauer (@mschauer) from https://github.com/JuliaPlots/Makie.jl/issues/355#issuecomment-504449775
Background: The algorithm puts an arrow somewhere and extends the streamline in both directions from there. Then, it chooses a new position (from the remaining ones), repeating the the exercise until the streamline gets blocked, from which on a new starting point, the process repeats.
So, ideally, the new starting points for streamlines are not too close to current streamlines.
Links:
AbstractPlotting.surface_normals
— Methodsurface_normals(x, y, z)
Normals for a surface defined on the grid xy
AbstractPlotting.ticklabels
— Methodticklabels(scene)
Returns the all the axis tick labels.
AbstractPlotting.tickranges
— Methodtickranges(scene)
Returns the tick ranges along all axes.
AbstractPlotting.tickrotations!
— Methodxtickrotation!([scene,] zangle)
Set the rotation of all tick labels.
AbstractPlotting.tickrotations
— Methodtickrotations(scene)
Returns the rotation of all tick labels.
AbstractPlotting.ticks!
— Functionticks!([scene,]; tickranges=tickranges(scene), ticklabels=ticklabels(scene))
Set the tick labels and ranges along all axes. The respective labels and ranges along each axis must be of the same length.
AbstractPlotting.to_func
— Methodto_func(Typ)
Maps the input of a Type name to its cooresponding function.
AbstractPlotting.to_spritemarker
— MethodAny AbstractMatrix{<: Colorant} or other image type
AbstractPlotting.to_spritemarker
— MethodVector of anything that is accepted as a single marker will give each point it's own marker. Note that it needs to be a uniform vector with the same element type!
AbstractPlotting.to_spritemarker
— Methodto_spritemarker(b, marker::Char)
Any Char
, including unicode
AbstractPlotting.to_spritemarker
— MethodMatrix of AbstractFloat will be interpreted as a distancefield (negative numbers outside shape, positive inside)
AbstractPlotting.to_spritemarker
— MethodA Symbol
- Available options can be printed with available_marker_symbols()
AbstractPlotting.to_string
— Methodto_string(func)
Turns the input of a function name or plot Type into a string.
AbstractPlotting.to_triangles
— Methodto_triangles(indices)
Convert a representation of triangle point indices indices
to its canonical representation as a Vector{AbstractPlotting.GLTriangleFace}
. indices
can be any of the following:
- An
AbstractVector{Int}
, containing groups of 3 1-based indices, - An
AbstractVector{UIn32}
, containing groups of 3 0-based indices, - An
AbstractVector
ofTriangleFace
objects, - An
AbstractMatrix
ofInteger
s, where each row is a triangle.
AbstractPlotting.to_type
— Methodto_type(func)
Maps the input of a function name to its cooresponding Type.
AbstractPlotting.to_vertices
— Methodto_vertices(v)
Converts a representation of vertices v
to its canonical representation as a Vector{Point3f0}
. v
can be:
An
AbstractVector
of 3-elementTuple
s orStaticVector
s,An
AbstractVector
ofTuple
s orStaticVector
s, in which case exta dimensions will be either truncated or padded with zeros as required,An
AbstractMatrix
"- if
v
has 2 or 3 rows, it will treat each column as a vertex, - otherwise if
v
has 2 or 3 columns, it will treat each row as a vertex.
- if
AbstractPlotting.used_attributes
— Methodused_attributes(args...) = ()
function used to indicate what keyword args one wants to get passed in convert_arguments
. Usage:
struct MyType end
used_attributes(::MyType) = (:attribute,)
function convert_arguments(x::MyType; attribute = 1)
...
end
# attribute will get passed to convert_arguments
# without keyword_verload, this wouldn't happen
plot(MyType, attribute = 2)
#You can also use the convenience macro, to overload convert_arguments in one step:
@keywords convert_arguments(x::MyType; attribute = 1)
...
end