'Is there a way to make grouped lines in a plotly plot?
i'm new to julia and very new at Plotly, so i'm strugling to get plots as I want.
Lets say I have some lists I want to plot but i would like to make it in group form so I can activate or deactivate this plots at same time:
x1_group1 = [-2,2,3]
y1_group1 = [3,2,-2]
x2_group1 = [-1,1]
y2_group1 = [0,0]
x1_group2 = [1,2]
y1_group2 = [1,3]
p1 = scatter(x=x1_group1,y=y1_group1)
p2 = scatter(x=x2_group1,y=y2_group1)
p3 = scatter(x=x1_group2,y=y1_group2)
plot([p1,p2,p3])
That's what i'm currently doing but I would like to get all lines in one plot but divided by groups, something like this:
Solution 1:[1]
Code:
using PlotlyJS
x1_group1 = [-2,2,3]
y1_group1 = [3,2,-2]
x2_group1 = [-1,1]
y2_group1 = [0,0]
x1_group2 = [1,2]
y1_group2 = [1,3]
p1 = scatter(
x=x1_group1,
y=y1_group1,
legendgroup="group1",
legendgrouptitle_text="1st Group",
name="1st legend group",
mode="lines"
)
p2 = scatter(
x=x2_group1,
y=y2_group1,
legendgroup="group1",
name="1st legend group",
mode="lines"
)
p3 = scatter(
x=x1_group2,
y=y1_group2,
legendgroup="group2",
legendgrouptitle_text="1st Group",
name="2nd legend group",
mode="lines"
)
plot([p1, p2, p3])
Output:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sanidhya Singh |


