# `Tucan.Axes`
[🔗](https://github.com/pnezis/tucan/blob/v0.6.0/lib/tucan/axes.ex#L1)

Utilities for configuring plot axes.

# `axis`

```elixir
@type axis() :: :x | :y
```

# `orient`

```elixir
@type orient() :: :bottom | :top | :left | :right
```

# `put_options`

```elixir
@spec put_options(vl :: VegaLite.t(), encoding :: atom(), options :: keyword()) ::
  VegaLite.t()
```

Sets an arbitrary set of options to the given `encoding` axis object.

Notice that no validation is performed, any option set will be merged with
the existing `axis` options of the given `encoding`.

An `ArgumentError` is raised if the given encoding channel is not defined.

# `set_color`

```elixir
@spec set_color(vl :: VegaLite.t(), color :: String.t()) :: VegaLite.t()
```

Sets the `color` of both `:x` and `:y` axes.

See also `set_color/3`.

# `set_color`

```elixir
@spec set_color(vl :: VegaLite.t(), axis :: axis(), color :: String.t()) ::
  VegaLite.t()
```

Set a specific color to the given axis.

## Examples

A scatter plot with the `y-axis` colored red and `x-axis` with a custom RGB color:

```tucan
Tucan.scatter(:iris, "petal_width", "petal_length")
|> Tucan.Axes.set_color(:y, "red")
|> Tucan.Axes.set_color(:x, "#2A32F4")
```

# `set_enabled`

```elixir
@spec set_enabled(vl :: VegaLite.t(), enabled :: boolean()) :: VegaLite.t()
```

Enables or disables both axes (`x`, `y`) at once.

See also `set_enabled/3`

# `set_enabled`

```elixir
@spec set_enabled(vl :: VegaLite.t(), axis :: axis(), enabled :: boolean()) ::
  VegaLite.t()
```

Enables or disables the given axis.

Notice that axes are enabled by default.

## Examples

```tucan
Tucan.scatter(:iris, "petal_width", "petal_length")
|> Tucan.Axes.set_enabled(:x, false)
|> Tucan.Axes.set_enabled(:y, false)
```

# `set_labels_angle`

```elixir
@spec set_labels_angle(vl :: VegaLite.t(), axis :: axis(), angle :: number()) ::
  VegaLite.t()
```

Set the rotation angle of the given axis labels.

By default, the label angle is -90 degrees for nominal and ordinal fields, and 0
degrees otherwise.

## Examples

A scatter plot with the `x-axis` labels rotated 45 degrees:

```tucan
Tucan.bar(%{x: ["Monday", "Tuesday", "Wednesday"], y: [4, 8, 2]}, "x", "y")
|> Tucan.Axes.set_labels_angle(:x, 45)
```

# `set_labels_enabled`

```elixir
@spec set_labels_enabled(vl :: VegaLite.t(), axis :: axis(), enabled :: boolean()) ::
  VegaLite.t()
```

Enables or disables the labels of the given axis.

## Examples

A scatter plot with both `x-axis` and `y-axis` labels disabled:

```tucan
Tucan.scatter(:iris, "petal_width", "petal_length")
|> Tucan.Axes.set_labels_enabled(:x, false)
|> Tucan.Axes.set_labels_enabled(:y, false)
```

# `set_offset`

```elixir
@spec set_offset(vl :: VegaLite.t(), axis :: axis(), offset :: number()) ::
  VegaLite.t()
```

Sets the axis offset (in pixels).

The offset indicates the amount in pixels by which the axis will be  displaces from the
edge of the enclosing group or data rectangle.

## Examples

```tucan
Tucan.scatter(:iris, "petal_width", "petal_length")
|> Tucan.Axes.set_offset(:y, 10)
|> Tucan.Grid.set_enabled(false)
```

# `set_orientation`

```elixir
@spec set_orientation(vl :: VegaLite.t(), axis :: axis(), orient :: orient()) ::
  VegaLite.t()
```

Sets the orientation for the given axis.

Valid values for `orient` are:

* `:top`, `:bottom` for the x axis
* `:left`, `:right` for the y axis

## Examples

```tucan
Tucan.scatter(:iris, "petal_width", "petal_length")
|> Tucan.Axes.set_orientation(:x, :top)
|> Tucan.Axes.set_orientation(:y, :right)
```

# `set_title`

```elixir
@spec set_title(vl :: VegaLite.t(), axis :: axis(), title :: String.t()) ::
  VegaLite.t()
```

Set the title of the given `axis`.

# `set_title_color`

```elixir
@spec set_title_color(vl :: VegaLite.t(), axis :: axis(), color :: String.t()) ::
  VegaLite.t()
```

Sets the title color of the given `axis`

## Examples

```tucan
Tucan.scatter(:iris, "petal_width", "petal_length")
|> Tucan.Axes.set_title_color(:x, "red")
|> Tucan.Axes.set_title_color(:y, "#F3B212")
```

# `set_x_title`

```elixir
@spec set_x_title(vl :: VegaLite.t(), title :: String.t()) :: VegaLite.t()
```

Sets the x axis title.

# `set_xy_titles`

```elixir
@spec set_xy_titles(vl :: VegaLite.t(), x_title :: String.t(), y_title :: String.t()) ::
  VegaLite.t()
```

Sets the _x-axis_ and _y-axis_ titles at once.

# `set_y_title`

```elixir
@spec set_y_title(vl :: VegaLite.t(), title :: String.t()) :: VegaLite.t()
```

Sets the y axis title.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
