plotly / plotly/plotly.R

Layout attribute "template"

Open
#1,817 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

After playing with plotly.py themes and templates options, I was wondering if it was possible to achieve the same result with plotly for R.

Although there is no themes available in R, I thought I could use the template options from the python themes and use them in a template in R.

In the plotly R figure reference, there is under "layout" the item "template" with the following description:

Parent: layout
Type: number or categorical coordinate string
Default attributes to be applied to the plot. Templates can be created from existing plots using Plotly.makeTemplate, or created manually. They should be objects with format: {layout: layoutTemplate, data: {[type]: [traceTemplate, ...]}, ...} layoutTemplate and traceTemplate are objects matching the attribute structure of layout and a data trace. Trace templates are applied cyclically to traces of each type. Container arrays (eg annotations) have special handling: An object ending in defaults (eg annotationdefaults) is applied to each array item. But if an item has a templateitemname key we look in the template array for an item with matching name and apply that instead. If no matching name is found we mark the item invisible. Any named template item not referenced is appended to the end of the array, so you can use this for a watermark annotation or a logo image, for example. To omit one of these items on the plot, make an item with matching templateitemname and visible: FALSE.

I have tried passing several possible argument to the template option of layout to no effect. Is there an option to use a template at the moment in plotly.R, and if so what is the proper syntax for the argument to pass?

Thank you very much for your help.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with the R figure reference's layout/template entry and compare it with the linked Python template documentation. Determine whether plotly.R already exposes template handling; done means either documenting the supported argument syntax or identifying the missing implementation and its required tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.