# PlotlyJS.plot(data) using data from a Dictionary

**URL:** https://discourse.julialang.org/t/plotlyjs-plot-data-using-data-from-a-dictionary/3775
**Category:** General Usage
**Tags:** question
**Created:** [May 17, 2017, 4:53pm UTC](https://discourse.julialang.org/t/plotlyjs-plot-data-using-data-from-a-dictionary/3775 "2017-05-17T16:53:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![PHP](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PHP](https://discourse.julialang.org/u/PHP)
#### Post date: [May 17, 2017, 4:53pm UTC](https://discourse.julialang.org/t/plotlyjs-plot-data-using-data-from-a-dictionary/3775/1 "2017-05-17T16:53:25Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ggggggggg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ggggggggg/32/265_2.png) [@ggggggggg](https://discourse.julialang.org/u/ggggggggg)
#### Post date: [May 17, 2017, 4:59pm UTC](https://discourse.julialang.org/t/plotlyjs-plot-data-using-data-from-a-dictionary/3775/2 "2017-05-17T16:59:47Z")

</div>

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"]]`.
