PlotlyJS.plot(data) using data from a Dictionary

data = [traceState[“traceAlabama”],
traceState[“traceAlaska”],
traceState[“traceArizona”]]

I am trying to produce the above code using for loop with the below code

data =
for j in state[:Area]
data = [data, traceState[“trace$j”]]
end

“state[:Area]” is an array with 50 States but it is not giving me what I want. I tried cat() and hcat() as well, but didn’t work. I also tried to directly convert the dictionary into value array format using values(traceState), but it was not in the correct format. “traceState” is a dictionary, and its keys are States and values are the scatter() function to be passed into. Eventually, I would like to use this data to run PlotlyJS.plot(data).

I’m not sure about the Plotly API, but if traceState is a Dict you may want values(traceState) or collect(values(traceState)). If you want a subset of the values you may want a comprehension, eg:

[traceState["trace$j"] for j in state[:Area]]  

And your code should work if you used push!(data, traceState["trace$j"]) instead of data = [data, traceState["trace$j"]].