Stackgroup with scatter and more than 1 axis not working properly?
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I am doing a scatter plot with stackgroups. I would like to use the x2 and y2 axises. When I use the regular x and y axis, the result is correct. The data frame below is used. The first Plotly chunk is for the regular x and y axis behavior. The second one tries to use x2 and y2 but only the 2nd stack group is shown. I think this might be a bug.
library(datasets)
df <- mtcars[1:5,]
df$mpg <- 0
df$qsec <- df$qsec + runif(length(df$qsec),min=-3, max=5)
df$hp <- df$hp + runif(length(df$hp),min=-30, max=30)
df$names <- rownames(df)
rownames(df) <- NULL
df2 <- mtcars[1:5,]
df2$names <- rownames(df2)
rownames(df2) <- NULL
df<- rbind(df,df2)
Below works but since the y axis range is quite different for qsec and hp, a second y axis is needed.
library(dplyr)
library(plotly)
plot_ly(type = "scatter",mode='none', width = 800, height=420) %>%
add_trace(
mode = "lines",
stackgroup = "red",
orientation = "h",
x = df$mpg,
y = df$qsec,
line = list(color = "red"),
name = df$names) %>%
add_trace(
mode = "lines",
stackgroup = "blue",
orientation = "h",
x = df$mpg,
y = df$hp,
line = list(color = "blue"),
name = df$names)%>%
layout( xaxis =list(title="mpg", side = "bottom"),
yaxis =list(title="qsec",side = "left"))
Here, the following is tried.
library(dplyr)
library(plotly)
plot_ly(type = "scatter",mode='none', width = 800, height=420) %>%
add_trace(
mode = "lines",
stackgroup = "red",
orientation = "h",
x = df$mpg,
y = df$qsec,
line = list(color = "red"),
name = df$names) %>%
add_trace(
mode = "lines",
stackgroup = "blue",
orientation = "h",
xaxis = "x2",
yaxis = "y2",
x = df$mpg,
y = df$hp,
line = list(color = "blue"),
name = df$names)%>%
layout( xaxis =list(title="mpg", side = "bottom"),
yaxis =list(title="qsec",side = "left")
,yaxis2 = list(title = "hp", side = "right", overlaying = "y")
,xaxis2 = list(title = "mpg", side = "top", overlaying = "y")
)
I also tried using fill = "tozerox" and fill = "tozeroy" instead of orientation="h"|"v" but this doesn't work at all. Thank you in advance for taking a look. :-)
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die beiden bereitgestellten R-Beispiele auszuführen, und vergleiche die Ausgabe, wenn der zweite Trace xaxis = "x2" und yaxis = "y2" mit stackgroup verwendet. Verfolge, wie add_trace und layout gestapelte Scatter-Traces über mehrere Achsen hinweg behandeln; das Issue ist abgeschlossen, wenn beide Stack-Gruppen mit den sekundären Achsen korrekt gerendert werden oder die unterstützte Einschränkung dokumentiert ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- plotly, r
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100