Change each trace meeting condition in PlotyJS plot

The title states it all. Here an example with the Julia code without the requested part.

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))

In Python a possible example of the requested part would be

# corresponding Python code of what I want to achieve in Julia
# adapt line style when the trace name ends with "_calc"
    lambda trace:
        ) if"_calc") else (),

Unfortunately I couldn’t find an equivalent of for_each_trace in the corresponding Julia documentation parts. I had a look at

Can this be achieved without such an equivalent command which is the reason it doesn’t exist?

for (k,it) in enumerate(
    if endswith(String(it[:name]), "_calc")
        restyle!(fig, k, line_dash="dash")
1 Like

@stephancb, awesome. I would have never come to Even can’t remember to have seen this anywhere. Many thanks !!

I had figured it out with

julia> fieldnames(typeof(fig))
(:plot, :scope, :window)

julia> fieldnames(typeof(fig.plot))
(:data, :layout, :frames, :divid, :config)

Just in case, we can also drill down by typing in the REPL: fig. followed by <TAB> <TAB>, and so on.

Or even better, use the new Eyeball package with the command: eye(fig)

I am new to Julia so I am very thankful for your hints, guys :+1: