添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
寂寞的登山鞋  ·  Solved: Trying to use ...·  10 月前    · 
稳重的豆腐  ·  [Json.NET] ...·  11 月前    · 
大鼻子的大熊猫  ·  Search - Government.se·  1 年前    · 
  • DataSet1: [+] Dataset: a data frame for illustrations
  • Datasets-sp: [+] Datasets of simulated spectroscopic data
  • expr2latex_: [!.] Translate 'plotmath' expressions to LaTeX and remove...
  • facet_wl: [!] Control facetting parameters in 'ggplot' of 'hyperSpec'...
  • gg_barplot: A barplot with counts above bars.
  • ggLims: [!] Convenience functions to get and set the axis limits in...
  • gg_palette: [!.] Add color palette to 'ggplot'
  • ggplot.hyperSpec: [!] 'ggplot' method for class 'hyperSpec'
  • highlight_ranges: Highlight wavelength ranges in a ggplot2 plot of hyperSpec...
  • label_expr2text: [!] Convert 'plotmath' expresions in labels to text
  • nTick: [+] Control number of ticks in 'ggplot2' plots with...
  • palette_PAP: [+] Color palette
  • plotly_annotation_rm: [!] Manage annotations in a 'plotly' object
  • plotly_modify_hover: [!] Modify hover in a 'plotly' object
  • plotly_modify_legend: [!] Modify legend of a 'plotly' object
  • plotly_tidy: Tidy up 'plotly' plot
  • spPlot: Various ploting functions for 'hyperSpec', 'ggplot2',...
  • subplot_1: Wrapper functions for plotly::subplot
  • Browse all...
  • Description

    Function allows modifying various legend options of object (plot) created with package plotly .

    Usage

    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
    

    Arguments

    a plotly object (created with function plot_ly, ggplotly, subplot or similar).

    showlegend

    logical, which determins if will be shown. If NULL (default) value of this option will not be changed.

    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 NULL (default) value of this option will not be changed.

    bordercolor

    Legend's border color. If NULL (default) value of this option will not be changed.

    borderwidth

    Legend's border width. If NULL (default) value of this option will not be changed.

    fontcolor

    Legend's font color. If NULL (default) value of this option will not be changed.

    fontfamily

    Legend's font family. If NULL (default) value of this option will not be changed.

    fontsize

    Legend's font size. If NULL (default) value of this option will not be changed.

    Legend's x position. If NULL (default) value of this option will not be changed.

    Legend's y position. If NULL (default) value of this option will not be changed.

    yanchor

    Described in R plotly reference.

    xanchor

    Described in R plotly reference.

    tracegroupgap

    Described in R plotly reference.

    orientation

    "v","h". If NULL (default) value of this option will not be changed. Described in R plotly reference.

    rm_rep_text, rm_repText

    (logical) If TRUE (default), repeated text in legend's label is removed.

    rm_nonfirst_gr

    (logical) If TRUE (default), non-first groups in legend's label is removed, e.g., "(ratio = 1.8,1,NA)" is converted to "ratio = 1.8".

    unique.legend

    logical. If TRUE (default), only one legend per legend group is shown. Result is visible if function subplot was applied.

    Further parameters to methods.

    Details

    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".

    Value

    An updated plotly object (class plotly).

    Author(s)

    Vilmantas Gegzna

    See Also

    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()

    Examples

    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)