Continuing the discussion from Change each trace meeting condition in PlotyJS plot:
Now I understand that the second argument in restyle!
can’t just be a single index, but also a vector of indices. So my question this time is, of there is a possibility to collect the indices of traces that meet a condition, e.g. with something like findall
?
The code is the same as before:
using DataFrames
using PlotlyJS
df = DataFrame(
x = 1:5,
a = rand(5),
b_calc = rand(5),
c = rand(5),
d_calc = rand(5)
)
fig = plot()
for tag in [:a, :b_calc, :c, :d_calc]
add_trace!(fig, scatter(x=df.x, y=df[!, tag], name=tag))
end
for (k,it) in enumerate(fig.plot.data)
if endswith(String(it[:name]), "_calc")
restyle!(fig, k, line_dash="dash")
end
end