Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Commit

Permalink
remove old content, make important makielayout things more prominent (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrumbiegel authored Jan 13, 2021
1 parent 2838d48 commit 7059158
Show file tree
Hide file tree
Showing 14 changed files with 421 additions and 358 deletions.
38 changes: 17 additions & 21 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -347,37 +347,33 @@ makedocs(
pages = Any[
"Home" => "index.md",
"Basics" => [
"basic-tutorial.md",
"plot_method_signatures.md",
"Basic Tutorial" => "basic-tutorial.md",
"Layout Tutorial" => "makielayout/tutorial.md",
"animation.md",
"interaction.md",
"plotting_functions.md",
"theming.md",
],
"Documentation" => [
"scenes.md",
"generated/axis.md",
"convenience.md",
"generated/plot-attributes.md",
"plot_method_signatures.md",
"Figure" => "figure.md",
"Axis" => "makielayout/laxis.md",
"GridLayout" => "makielayout/grids.md",
"Legend" => "makielayout/llegend.md",
"Other Layoutables" => "makielayout/layoutables_examples.md",
"How Layouting Works" => "makielayout/layouting.md",
"generated/colors.md",
"lighting.md",
"cameras.md",
"generated/plot-attributes.md",
"recipes.md",
"output.md",
"backends.md",
"troubleshooting.md",
"output.md",
"scenes.md",
"lighting.md",
"cameras.md",
"faq.md",
"API Reference AbstractPlotting" => "abstractplotting_api.md",
],
"MakieLayout" => [
"Tutorial" => "makielayout/tutorial.md",
"GridLayout" => "makielayout/grids.md",
"Axis" => "makielayout/laxis.md",
"Special Plots" => "makielayout/special_plots.md",
"Legend" => "makielayout/llegend.md",
"Layoutables Examples" => "makielayout/layoutables_examples.md",
"How Layouting Works" => "makielayout/layouting.md",
"Frequently Asked Questions" => "makielayout/faq.md",
"API Reference" => "makielayout/reference.md",
"API Reference MakieLayout" => "makielayout/reference.md",
"generated/axis.md",
],
],
strict = true, # experimental kwarg, so that the docs fail if there are any errors encountered
Expand Down
2 changes: 1 addition & 1 deletion docs/src/basic-tutorial.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tutorial
# Basic Tutorial

Here is a quick tutorial to get you started. We assume you have [Julia](https://julialang.org/) and `GLMakie.jl` (or one of the other backends) installed already.

Expand Down
27 changes: 0 additions & 27 deletions docs/src/convenience.md

This file was deleted.

108 changes: 73 additions & 35 deletions docs/src/troubleshooting.md → docs/src/faq.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,22 @@
# Troubleshooting
# Frequently Asked Questions

## Installation issues
## Installation Issues

Here, we assume you are running Julia on the vanilla system image - no PackageCompiler goodness. If you are using `PackageCompiler`, check out the page on compilation.
We assume you are running Julia on the default system image without PackageCompiler.

### No `Scene` displayed or GLMakie fails to build

If `Makie` builds, but when a plotting, no `Scene` is displayed, as in:

```julia
julia> using Makie

julia> lines([0,1], [0,1])
Scene (960px, 540px):
events:
window_area: GeometryTypes.HyperRectangle{2,Int64}([0, 0], [0, 0])
window_dpi: 100.0
window_open: false
mousebuttons: Set(AbstractPlotting.Mouse.Button[])
mouseposition: (0.0, 0.0)
mousedrag: notpressed
scroll: (0.0, 0.0)
keyboardbuttons: Set(AbstractPlotting.Keyboard.Button[])
unicode_input: Char[]
dropped_files: String[]
hasfocus: false
entered_window: false
plots:
*Axis2D{...}
*Lines{...}
subscenes:
*scene(960px, 540px)
```

then, your backend may not have built correctly. By default, Makie will try to use GLMakie as a backend, but if it does not build correctly for whatever reason, then scenes will not be displayed.
If `Makie` builds, but when plotting no window or plot is displayed, your backend may not have built correctly.
By default, Makie will try to use GLMakie as a backend, but if it does not build correctly for whatever reason, then scenes will not be displayed.
Ensure that your graphics card supports OpenGL; if it does not (old models, or relatively old integrated graphics cards), then you may want to consider CairoMakie.

# Plotting issues
## Plotting issues

## Dimension too large
### Dimensions too large

In general, plotting functions tend to plot whatever's given to them as a single texture. This can lead to GL errors, or OpenGL failing silently. To circumvent this, one can 'tile' the plots (i.e., assemble them piece-by-piece) to decrease the individual texture size.

### 2d plots (heatmaps, images, etc.)
#### 2d plots (heatmaps, images, etc.)

```julia
heatmap(rand(Float32, 24900, 26620))
Expand Down Expand Up @@ -70,7 +44,7 @@ heatmap!(sc, (size(data, 1)÷2 + 1):size(data, 1), (size(data, 2)÷2 + 1):size(d
```
![tiled heatmap](https://user-images.githubusercontent.com/32143268/61105143-a3b35780-a496-11e9-83d1-bebe549aa593.png)

### 3d plots (volumes)
#### 3d plots (volumes)

The approach here is similar to that for the 2d plots, except that here there is a helpful function that gives the maximum texture size.
You can check the maximum texture size with:
Expand Down Expand Up @@ -112,3 +86,67 @@ If `Makie` can't find your font, you can do two things:
- `ENV["FREETYPE_ABSTRACTION_FONT_PATH"] = "/path/to/your/fonts"`

3) Specify the path to the font; instead of `font = "Noto"`, you could write `joindir(homedir(), "Noto.ttf")` or something.


## Layout Issues

```@eval
using CairoMakie
CairoMakie.activate!()
```

### Elements are squashed into the lower left corner

Layoutable elements require a bounding box that they align themselves to. If you
place such an element in a layout, the bounding box is controlled by that layout.
If you forget to put an element in a layout, it will have its default bounding box
of `BBox(0, 100, 0, 100)` which ends up being in the lower left corner. You can
also choose to specify a bounding box manually if you need more control.

```@example
using CairoMakie
scene, layout = layoutscene(resolution = (1200, 1200))
ax1 = Axis(scene, title = "Squashed")
ax2 = layout[1, 1] = Axis(scene, title = "Placed in Layout")
ax3 = Axis(scene, bbox = BBox(400, 800, 400, 800),
title = "Placed at BBox(400, 800, 400, 800)")
save("faq_squashed_element.svg", scene); nothing # hide
```

![squashed elements](faq_squashed_element.svg)


### Columns or rows are shrunk to the size of Text or another element

Columns or rows that have size `Auto(true)` try to determine the width or height of all
single-spanned elements that are placed in them, and if any elements report their
size the row or column will shrink to the maximum reported size. This is so smaller
elements with a known size take as little space as needed. But if there is other
content in the row that should take more space, you can give the offending element
the attribute `tellheight = false` or `tellwidth = false`. This way, its own size
can be determined automatically, but
it doesn't report it to the row or column of the layout. Alternatively, you can set the size
of that row or column to `Auto(false)` (or any other value than `Auto(true)`).

```@example
using CairoMakie
scene, layout = layoutscene(resolution = (1200, 1200))
layout[1, 1] = Axis(scene, title = "Shrunk")
layout[2, 1] = Axis(scene, title = "Expanded")
layout[1, 2] = Label(scene, "tellheight = true", tellheight = true)
layout[2, 2] = Label(scene, "tellheight = false", tellheight = false)
save("faq_shrunk_row.svg", scene); nothing # hide
```

![shrunk row](faq_shrunk_row.svg)

```@eval
using GLMakie
GLMakie.activate!()
```
142 changes: 142 additions & 0 deletions docs/src/figure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Figure

The `Figure` object contains a top-level `Scene` and a `GridLayout`, as well as a list of layoutables that have been placed into it, like `Axis`, `Colorbar`, `Slider`, `Legend`, etc.

!!! note
Wherever you see the old `scene, layout = layoutscene()` workflow from MakieLayout, you can imagine that
the `Figure` takes over the role of both `scene` and `layout`, plus additional conveniences like keeping
track of layoutables.

## Creating A Figure

You can create a figure explicitly with the `Figure()` function, and set attributes of the underlying scene.
The most important one of which is the `resolution`.

```julia
f = Figure()
f = Figure(resolution = (600, 400))
```

A figure is also created implicitly when you use simple, non-mutating plotting commands like `plot()`, `scatter()`, `lines()`, etc.
Because these commands also create an axis for the plot to live in and the plot itself, they return a compound object `FigureAxisPlot`, which just stores these three parts.
To access the figure you can either destructure that object into its three parts or access the figure field directly.

```julia
figureaxisplot = scatter(rand(100, 2))
figure = figureaxisplot.figure

# destructuring syntax
figure, axis, plot = scatter(rand(100, 2))

# you can also ignore components
figure, _ = scatter(rand(100, 2))
```

You can pass arguments to the created figure in a dict-like object to the special `figure` keyword:

```julia
scatter(rand(100, 2), figure = (resolution = (600, 400),))
```

## Placing Layoutables Into A Figure

All layoutables take their parent figure as the first argument, then you can place them in the figure layout
via indexing syntax.

```julia
f = Figure()
ax = f[1, 1] = Axis(f)
sl = f[2, 1] = Slider(f)
```

## FigurePositions and FigureSubpositions

The indexing syntax of `Figure` is implemented to work seamlessly with layouting.
If you index into the figure, a `FigurePosition` object that stores this indexing operation is created.
This object can be used to plot a new axis into a certain layout position in the figure, for example like this:

```@example
using GLMakie
f = Figure()
pos = f[1, 1]
scatter(pos, rand(100, 2))
pos2 = f[1, 2]
lines(pos2, cumsum(randn(100)))
# you don't have to store the position in a variable first, of course
heatmap(f[1, 3], randn(10, 10))
f
```

You can also index further into a `FigurePosition`, which creates a `FigureSubposition`.
With `FigureSubposition`s you can describe positions in arbitrarily nested grid layouts.
Often, a desired plot layout can only be achieved with nesting, and repeatedly indexing makes this easy.

```@example
using GLMakie
f = Figure()
f[1, 1] = Axis(f, title = "I'm not nested")
f[1, 2][1, 1] = Axis(f, title = "I'm nested")
# plotting into nested positions also works
heatmap(f[1, 2][2, 1], randn(20, 20))
f
```

All nested grid layouts that don't exist yet, but are needed for a nested plotting call, are created in the background automatically.

!!! note
The `GridLayout`s that are implicitly created when using `FigureSubpositions` are not directly available in the return
value for further manipulation. You can instead retrieve them after the fact with the `content` function, for example,
as explained in the following section.

## Retrieving Objects From A Figure

Sometimes users are surprised that indexing into a figure does not retrieve the object placed at that position.
This is because the `FigurePosition` is needed for plotting, and returning content objects directly would take
away that possibility.
Furthermore, a `GridLayout` can hold multiple objects at the same position, or have partially overlapping content,
so it's not well-defined what should be returned given a certain index.

To retrieve objects from a Figure you can instead use indexing plus the `contents` or `content` functions.
The `contents` function returns a Vector of all objects found at the given `FigurePosition`.
You can use the `exact = true` keyword argument so that the position has to match exactly, otherwise objects
contained in that position are also returned.

```julia
f = Figure()
box = f[1:3, 1:2] = Box(f)
ax = f[1, 1] = Axis(f)

contents(f[1, 1]) == [ax]
contents(f[1:3, 1:2]) == [box, ax]
contents(f[1:3, 1:2], exact = true) == [box]
```

If you use `contents` on a `FigureSubposition`, the `exact` keyword only refers to the lowest-level
grid layout, all upper levels have to match exactly.

```julia
f = Figure()
ax = f[1, 1][2, 3] = Axis(f)

contents(f[1, 1][2, 3]) == [ax]
contents(f[1:2, 1:2][2, 3]) == [] # the upper level has to match exactly
```

Often, you will expect only one object at a certain position and you want to work directly with it, without
retrieving it from the Vector returned by `contents`.
In that case, use the `content` function instead.
It works equivalently to `only(contents(pos, exact = true))`, so it errors if it can't return exactly one object
from an exact given position.

```julia
f = Figure()
ax = f[1, 1] = Axis(f)

contents(f[1, 1]) == [ax]
content(f[1, 1]) == ax
```
Loading

0 comments on commit 7059158

Please sign in to comment.