Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/plotly_modify_legend.R
Function allows modifying various legend options of object (plot) created with package plotly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | plotly_modify_legend(
obj,
showlegend = NULL,
traceorder = NULL,
bgcolor = NULL,
bordercolor = NULL,
borderwidth = NULL,
fontcolor = NULL,
fontfamily = NULL,
fontsize = NULL,
x = NULL,
y = NULL,
yanchor = NULL,
xanchor = NULL,
tracegroupgap = NULL,
orientation = NULL,
rm_rep_text = TRUE,
rm_nonfirst_gr = TRUE,
unique.legend = TRUE,
...,
rm_repText = rm_rep_text
)
|
obj |
a plotly object (created with function |
showlegend |
logical, which determins if will be shown.
If |
traceorder |
Any combination of "reversed", "grouped" joined with a "+" OR "normal". examples: "reversed", "grouped", "reversed+grouped", "normal" Determines the order at which the legend items are displayed. If "normal", the items are displayed top-to-bottom in the same order as the input data. If "reversed", the items are displayed in the opposite order as "normal". If "grouped", the items are displayed in groups (when a trace 'legendgroup' is provided). if "grouped+reversed", the items are displayed in the opposite order as "grouped". Described in R plotly reference. |
bgcolor |
Legend's background color. If |
bordercolor |
Legend's border color. If |
borderwidth |
Legend's border width. If |
fontcolor |
Legend's font color. If |
fontfamily |
Legend's font family. If |
fontsize |
Legend's font size. If |
x |
Legend's x position. If |
y |
Legend's y position. If |
yanchor |
Described in R plotly reference. |
xanchor |
Described in R plotly reference. |
tracegroupgap |
Described in R plotly reference. |
orientation |
"v","h". If |
rm_rep_text, rm_repText |
(logical) If |
rm_nonfirst_gr |
(logical) If |
unique.legend |
logical. If |
... |
Further parameters to methods. |
If option rm_repText
is TRUE
(default), function corrects text
in legend of object created with function ggplotly
so
that only relevant information is displayed.
For example, if the text in a label is "(matrix,matrix,matrix)"
, it is
converted to shorter string "matrix"
.
An updated plotly object (class plotly
).
Vilmantas Gegzna
Online reference https://plot.ly/r/reference/#layout-legend;
Functions layout(), plot_ly(),
Other spPlot functions for plotly:
label_expr2text()
,
plotly_annotation_rm()
,
plotly_modify_hover()
,
plotly_tidy()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | library(spPlot)
library(spHelper)
library(hyperSpec)
library(plotly)
# Create `plotly` object:
obj <- qplot_spStat(chondro, "clusters", mean) %>%
label_expr2text() %>%
ggplotly()
# Then compare this plot:
plotly_modify_legend(obj)
# With the original one:
print(obj)
# More options
plotly_modify_legend(obj, traceorder = "reversed")
plotly_modify_legend(obj, showlegend = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.