# Passing a field from a user type vector to plot using Plots

**URL:** <https://discourse.julialang.org/t/passing-a-field-from-a-user-type-vector-to-plot-using-plots/15389>\
**Category:** New to Julia\
**Created:** [September 23, 2018, 4:50pm UTC](https://discourse.julialang.org/t/passing-a-field-from-a-user-type-vector-to-plot-using-plots/15389 "2018-09-23T16:50:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fanny](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@Fanny](https://discourse.julialang.org/u/Fanny)\
**Post date:** [September 23, 2018, 4:50pm UTC](https://discourse.julialang.org/t/passing-a-field-from-a-user-type-vector-to-plot-using-plots/15389/1 "2018-09-23T16:50:15Z")

</div>

When I pass a dummy array to the plot routine everything is fine. When I pass a vector from a field of a user define type I get an error. The error is: type Array does not contain a field XX. Is there a way to do this without creating a dummy array from the user type field.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [September 23, 2018, 6:41pm UTC](https://discourse.julialang.org/t/passing-a-field-from-a-user-type-vector-to-plot-using-plots/15389/2 "2018-09-23T18:41:08Z")

</div>

Welcome to the forums! It sounds a bit like you’ve got a syntax bug somewhere - if you’re giving a vector, wherever it comes from, it should work. But it’s hard to know exactly what’s happening without seeing the code. Can you make a minimum working example?

Also, take a look at [this post](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/), which has some helpful suggestions about how to post a question and maximize the chances that someone can help.

---

<div class="post-metadata">

**Author:** ![Fanny](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@Fanny](https://discourse.julialang.org/u/Fanny)\
**Post date:** [September 24, 2018, 3:18pm UTC](https://discourse.julialang.org/t/passing-a-field-from-a-user-type-vector-to-plot-using-plots/15389/3 "2018-09-24T15:18:51Z")

</div>

Thanks for your thoughts. I’ve am now including an example to help explain my error? See below

This runs and plots the result  
using Plots  
feed = zeros(10,2)  
dummy = zeros(10)  
mutable struct Feed  
x::Float64  
y::Float64  
end  
feed = [Feed(100.0,40.0) for \_ = 1:10]  
for i in 1:10  
dummy[i] = feed[i].x  
end  
plot(1.0:10.0,dummy[1:10])

This gave me a load error type Array has no field x:  
using Plots  
feed = zeros(10,2)  
dummy = zeros(10)  
mutable struct Feed  
x::Float64  
y::Float64  
end  
feed = [Feed(100.0,40.0) for \_ = 1:10]  
plot(1:10,feed[1:10].x)
