Foresight
Documentation for Foresight.
Foresight.Lscientific
Foresight.addlabels!
Foresight.addlabels!
Foresight.axiscolorbar
Foresight.brighten
Foresight.clip
Foresight.darken
Foresight.demofigure
Foresight.foresight
Foresight.freeze!
Foresight.importall
Foresight.lscientific
Foresight.prism
Foresight.scientific
Foresight.seethrough
Foresight.subdivide
Foresight.widen
Foresight.@default_theme!
Foresight.Lscientific
— Methodlscientific(x::Real, sigdigits=2)
Return a string representation of a number in scientific notation with a specified number of significant digits, as a LaTeXString. See lscientific
Example
x = Lscientific(1/123.456, 2) # L"8.10 \times 10^{-3}"
Foresight.addlabels!
— Functionaddlabels!(gridpositions, f::Figure, [text]; dims=2, kwargs...)
Add labels to a provided grid layout. The labels are incremented in the linear order of the grid positions.
Arguments
gridpositions
: An iterator ofGridPosition
s as produced by e.g.subdivide
.f
: The figure associated with the grid positions (optional)text
: Text to be displayed in the labels, as either an interator of strings or a function applied to the integer indices of the grid positions [optional; defaults to (a), (b), ...]kwargs
: Keyword arguments to be passed to theLabel
function.
Examples
f = Figure()
gs = subdivide(f, 2, 2)
addlabels!(gs)
display(f)
Foresight.addlabels!
— Functionaddlabels!(f::Figure, [text]; dims=2, allowedblocks = [Axis, Axis3, PolarAxis], recurse =
[GridContent, GridLayout], kwargs...)
Add labels to a provided grid layout, automatically searching for blocks to label.
Arguments
f
: The figure to add labels to.text
: Text to be displayed in the labels, as either an interator of strings or a function applied to the integer indices of the grid positions [optional; defaults to (a), (b), ...]dims
: The dimension to increment labels;1
for top-to-bottom increases (column major), or2
for right-to-left increases (row-major; default).allowedblocks
: The types of blocks to consider for labelling (optional; defaults to[Axis, Axis3, PolarAxis]
).recurse
: The types of blocks to recurse into for searching theallowedblocks
(optional; defaults to[GridContent, GridLayout]
).kwargs
: Keyword arguments to be passed to theLabel
function.
Examples
f = Foresight.demofigure()
addlabels!(f)
display(f)
See also: addlabels!
Foresight.axiscolorbar
— Methodaxiscolorbar(ax, args...; kwargs...)
Create a colorbar for the given ax
axis. The args
argument is passed to the Colorbar
constructor, and the kwargs
argument is passed to the Colorbar
constructor as keyword arguments. The position
argument specifies the position of the colorbar relative to the axis, and can be one of :rt
(right-top), :rb
(right-bottom), :lt
(left-top), :lb
(left-bottom). The default value is :rt
.
Example
f = Figure()
ax = Axis(f[1, 1])
x = -5:0.01:5
p = plot!(ax, x, x->sinc(x), color=1:length(x), colormap=sunset)
axiscolorbar(ax, p; label="Time (m)")
Foresight.brighten
— Methodbrighten(c::T, β)
Brighten a color c
by a factor of β
by blending it with white. β
should be between 0 and 1.
Example
brighten(cornflowerblue, 0.5)
Foresight.clip
— Functiontmpfile = clip(fig=Makie.current_figure(), fmt=:png; kwargs...)
Save the current figure to a temporary file and copy it to the clipboard. kwargs
are passed to Makie.save
.
Example
f = plot(-5:0.01:5, x->sinc(x))
clip(f)
Foresight.darken
— Methoddarken(c::T, β)
Darken a color c
by a factor of β
by blending it with black. β
should be between 0 and 1.
Example
darken(cornflowerblue, 0.5)
Foresight.demofigure
— Methoddemofigure()
Produce a figure showcasing the current theme.
Foresight.foresight
— Methodforesight(options...; fonts=foresightfonts())
Return the default Foresight theme. The options
argument can be used to modify the default values, by passing keyword arguments with the names of the attributes to be changed and their new values.
Some vailable options are:
:dark
: Use a dark background and light text.:transparent
: Make the background transparent.:minorgrid
: Show minor gridlines.:serif
: Use a serif font.:redblue
: Use a red-blue colormap.:gray
: Use a grayscale colormap.:physics
: Set a theme that resembles typical plots in physics journals.
Foresight.freeze!
— Methodfreeze!(ax::Union{Axis, Axis3, Figure}=current_figure())
Freeze the limits of an Axis or Axis3 object at their current values.
Example
ax = Axis();
plot!(ax, -5:0.01:5, x->sinc(x))
freeze!(ax)
Foresight.importall
— Methodimportall(module)
Return an array of expressions that can be used to import all names from a module.
Example
importall(module) .|> eval
Foresight.lscientific
— Functionlscientific(x::Real, sigdigits=2)
Return a string representation of a number in scientific notation with a specified number of significant digits. This is not a LaTeXString. See Lscientific
Example
x = lscientific(1/123.456, 2) # "8.10 \times 10^{-3}"
l = LaTeXString(x)
Foresight.prism
— Methodprism(x, Y; [palette=[:cornflowerblue, :crimson, :cucumber], colormode=:top, verbose=false.])
Color a covariance matrix each element's contribution to each of the top k
principal components, where k
is the length of the supplied color palette (defaults to the number of principal component weights given). Provide as positional arguments a vector x
of N row names and an N×N covariance matrix Y
.
Keyword Arguments
palette
: a vector containing a color for each principal component.colormode
: how to color the covariance matrix.:raw
gives no coloring by principal components,:top
is a combination of the top three PC colors (default) and:all
is a combination of all PC colors, where PCN = :black if N > length(palette).verbose
: whether to print the feature weights to the console
Foresight.scientific
— Functionscientific(x::Real, sigdigits=2)
Generate string representation of a number in scientific notation with a specified number of significant digits.
Arguments
x::Real
: The number to be formatted.sigdigits::Int=2
: The number of significant digits to display.
Example
scientific(1/123.456, 2) # "8.10 × 10⁻³"
Foresight.seethrough
— Functionseethrough(C::ContinuousColorGradient, start=0.0, stop=1.0)
Convert a color gradient into a transparent version
Examples
C = sunrise;
transparent_gradient = seethrough(C)
Foresight.subdivide
— Methodsubdivide(f, nrows::Int, ncols::Int)::Matrix{GridPosition}
Subdivides a figure f
into a grid with specified number of rows and columns. Returns the corresponding grid positions
Example
f = Figure()
gs = subdivide(f, 2, 2)
axs = Axis.(gs)
display(f)
Foresight.widen
— FunctionSlightly widen an interval by a fraction δ
Foresight.@default_theme!
— Macro@default_theme!(thm)
Set the default theme to thm
and save it as a preference. The change will take effect after restarting Julia.
Example
@default_theme!(foresight())