Foresight.jl

A Makie theme
Author brendanjohnharris
Popularity
6 Stars
Updated Last
3 Months Ago
Started In
November 2022

Foresight.jl

Stable Dev Build Status Coverage

A Makie theme. And some cool utilities.

Usage

using CairoMakie
using Foresight
foresight() |> Makie.set_theme!
fig = Foresight.demofigure()

demo

Theme options

Any combination of the keywords below can be used to customise the theme.

Dark

foresight(:dark, :transparent) |> Makie.set_theme!
fig = Foresight.demofigure()

demo

Transparent

foresight(:dark, :transparent) |> Makie.set_theme!
fig = Foresight.demofigure()

demo

Serif

foresight(:serif) |> Makie.set_theme!
fig = Foresight.demofigure()

demo

Physics

foresight(:physics) |> Makie.set_theme!
fig = Foresight.demofigure()

demo

Utilities

addlabels!

Add labels to a provided grid layout, automatically searching for blocks to label.

f = Foresight.demofigure()
addlabels!(f)
display(f)

seethrough

Converts a color gradient into a transparent version.

C = cgrad(:viridis)
transparent_gradient = seethrough(C)

scientific

Generate string representation of a number in scientific notation with a specified number of significant digits.

scientific(1/123.456, 3) # "8.10 ร— 10โปยณ"

There is also an lscientific method, which returns a LaTeX string:

lscientific(1/123.456, 3) # "8.10 \\times 10^{-3}"

brighten and darken

Brighten a color by a given factor by blending it with white:

brighten(:cornflowerblue, 0.2) # Brightens the color by 20%

Or, darken a color by blending it with black:

darken(:cornflowerblue, 0.2) # Darkens the color by 20%

widen

Slightly widens an interval by a fraction ฮด.

x = (0.0, 1.0)
wider_interval = Foresight.widen(x, 0.1)

freeze!

Freezes the axis limits of a Makie figure.

fig, ax, plt = scatter(rand(10), rand(10))
freeze!(ax)

clip

Copies a Makie figure to the clipboard.

fig = Figure()
scatter!(fig[1, 1], rand(10), rand(10))
clip(fig)

@importall

Imports all symbols from a module into the current scope. Use with caution.

@importall(Foresight) .|> eval

hidexaxis! and hideyaxis!

Hides the x-axis or y-axis, respectively, of a given axis object.

fig, ax, plt = scatter(rand(10), rand(10))
hidexaxis!(ax)
hideyaxis!(ax)

gtkshow

Displays a CairoMakie scene, axis, figure, or FigureAxisPlot in a new GTK window. If Gtk is loaded, this is the default display method for CairoMakie figures. Useful for X-forwarding CairoMakie outputs from e.g. a remote cluster.

using CairoMakie, Gtk
using Foresight
scene = CairoMakie.Scene()
gtkshow(scene)

Colors

The theme is based on the colors [cornflowerblue, crimson, cucumber, california, juliapurple]:

palette

It also provides the following colormaps:

sunrise

sunrise

cyclicsunrise

cyclicsunrise

sunset

sunset

darksunset

darksunset

lightsunset

lightsunset

binarysunset

binarysunset

cyclic

cyclic

pelagic

pelagic

Recipes

The following recipes are exported:

ziggurat

A transparent stepped histogram, shown in the demo figure above.

hill

A transparent kernel density plot, shown in the demo figure above.

prism

Colors a positive definite matrix according to its eigendecomposition. prism prism

covellipse

Plot an ellipse representing a given covariance matrix. prism prism