10.10 Layout: Axes

  • See all the options here
  • layout = list(xaxis = list(...), yaxis = list(...))
p <- plot_ly(data = swiss, x = ~Catholic, y = ~Fertility, type = "scatter", mode = "markers")
  layout(p, autosize = T,
         
         xaxis = list(
            name = "Fertility",
            showexponent = "all",
            showticklabels = TRUE,
            color = "black",
            # categoryarray (dataframe column, list, vector) Sets the order 
            # in which categories on this axis appear. Only has an effect 
            # if `categoryorder` is set to "array". Used with `categoryorder`.
            #showticksuffix = "all",
            titlefont = list(color = "red", family = "Times New Roman", size = 12),
            linecolor = "red",
            mirror = TRUE,
            tickvalssrc = list(nticks = 3, linewidth = 4, autorange = TRUE),
            ticktextsrc = list(tickprefix = "-", position = 0, tickformat = "", tickmode = "auto"),
            title = "Fertility",
            ticks = "outside",
            overlaying = "free",
            rangemode = "normal",
            showtickprefix = "all",
            zeroline = TRUE,
            domain = "[0, 2]", ## ???
            gridcolor = "red",
            type = "-", #(enumerated: "-" | "linear" | "log" | 
            #"date" | "category" ), X-axis type
            separatethousands = TRUE, # Sep. 1000s
            zerolinewidth = 2,
            ticklen = 8,
            categoryorder = "trace", #(enumerated: "trace" | "category ascending"
            #| "category descending" | "array" )
            hoverformat = "",
            ticksuffix = "y",
            fixedrange = FALSE, # allow x-axis zoom
            showline = TRUE,
            # ticktext (dataframe column, list, vector) Sets the text 
            #displayed at the ticks position via `tickvals`. Only has 
            #an effect if `tickmode` is set to "array". Used with `tickvals`
            showgrid = TRUE,
            # tickvals (dataframe column, list, vector) Sets the values at 
            #which ticks on this axis appear. Only has an effect if 
            #`tickmode` is set to "array". Used with `ticktext`.
            tickfont = list(color = "green", family = "Arial", size = 13),
            tickwidth = 3,
            tick0 = 0, # position of first tick
            dtick = 10, # tick interval
            tickangle = 45,
            gridwidth = 2,
            # side (enumerated: "top" | "bottom" | "left" | "right" ) 
            zerolinecolor = "blue",
            range = c(0,50),
            tickcolor = "yellow",
            anchor = "free"
            # exponentformat (enumerated: "none" | "e" | "E" | "power" | "SI" | "B" ) # formatting of tick exponent
         )
         
         )