plotly / plotly/plotly.R

Bug with legend position and the title of the second y axis

Open
#1,808 0 comments 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

When using plotly, I'm trying to have multiple axes on my graph, but when I switch the legend side to horizontal, the second y axis label overlays the ticks and is impossible to read. to show the problem, I'll use the exemple in the R plotly documentation, except that I add one line : legend = list(orientation = 'h'). The output it produces is attached. I can fix the problem by manually adding a marging, but I don't think that is the desired output of your function.
bug_yaxis
sorry for the broken reprex, I don't know how to add plotly as a library into the reprex.

Best
Xav


ay <- list(
  tickfont = list(color = "red"),
  overlaying = "y",
  side = "right",
  title = "second y axis"
)
fig <- plot_ly()
#> Error in plot_ly(): impossible de trouver la fonction "plot_ly"
fig <- fig %>% add_lines(x = ~1:3, y = ~10*(1:3), name = "slope of 10")
#> Error in fig %>% add_lines(x = ~1:3, y = ~10 * (1:3), name = "slope of 10"): impossible de trouver la fonction "%>%"
fig <- fig %>% add_lines(x = ~2:4, y = ~1:3, name = "slope of 1", yaxis = "y2")
#> Error in fig %>% add_lines(x = ~2:4, y = ~1:3, name = "slope of 1", yaxis = "y2"): impossible de trouver la fonction "%>%"
fig <- fig %>% layout(
  title = "Double Y Axis", yaxis2 = ay,
  xaxis = list(title="x"),
  legend = list(orientation = 'h')
)
#> Error in fig %>% layout(title = "Double Y Axis", yaxis2 = ay, xaxis = list(title = "x"), : impossible de trouver la fonction "%>%"

fig
#> Error in eval(expr, envir, enclos): objet 'fig' introuvable

Created on 2020-07-01 by the reprex package (v0.3.0)


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

Start by reproducing the R plotly documentation example with a second y axis and legend = list(orientation = 'h'); the issue does not name a source file or test. Compare the resulting layout with the attached output, and consider the issue done when the second y-axis title is readable without manually adding a margin.

Written by the indexing model from the issue text.

Assessment

Tech stack
plotly, r
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.