# Add grids on chart — ax_grid • apexcharter

Add grids on chart

    ax_grid(
      ax,
      show = NULL,
      borderColor = NULL,
      strokeDashArray = NULL,
      position = NULL,
      xaxis = NULL,
      yaxis = NULL,
      row = NULL,
      column = NULL,
      padding = NULL,
      ...
    )

## Arguments

ax

  A `apexcharts` `htmlwidget` object.

show

  Logical. To show or hide grid area (including xaxis / yaxis)

borderColor

  Colors of grid borders / lines.

strokeDashArray

  Creates dashes in borders of svg path. Higher number creates more space between dashes in the border.

position

  Whether to place grid behind chart paths of in front. Available options for position: `"front"` or `"back"`

xaxis

  A list of parameters.

yaxis

  A list of parameters.

row

  A list of parameters.

column

  A list of parameters.

padding

  A list of parameters.

...

  Additional parameters.

## Value

A `apexcharts` `htmlwidget` object.

## Note

See https://apexcharts.com/docs/options/grid/

## Examples

    data("mpg", package = "ggplot2")

    # Hide Y-axis and gridelines
    apex(
      data = mpg,
      mapping = aes(x = manufacturer)
    ) %>%
      ax_grid(show = FALSE)

    # just grid lines
    apex(
      data = mpg,
      mapping = aes(x = manufacturer)
    ) %>%
      ax_grid(yaxis = list(lines = list(show = FALSE)))

    # both x & y
    data("economics", package = "ggplot2")
    apex(
      data = economics,
      mapping = aes(x = date, y = psavert),
      type = "line"
    ) %>%
      ax_grid(
        yaxis = list(lines = list(show = TRUE)),
        xaxis = list(lines = list(show = TRUE))
      )