# Agent based model - create scatter plot with agent variables from data frame

**URL:** <https://discourse.julialang.org/t/agent-based-model-create-scatter-plot-with-agent-variables-from-data-frame/115553>\
**Category:** New to Julia\
**Tags:** question, plotting, dataframes, agents\
**Created:** [June 12, 2024, 1:28pm UTC](https://discourse.julialang.org/t/agent-based-model-create-scatter-plot-with-agent-variables-from-data-frame/115553 "2024-06-12T13:28:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tfranks](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@tfranks](https://discourse.julialang.org/u/tfranks)\
**Post date:** [June 12, 2024, 1:28pm UTC](https://discourse.julialang.org/t/agent-based-model-create-scatter-plot-with-agent-variables-from-data-frame/115553/1 "2024-06-12T13:28:21Z")

</div>

Hello,

I’ve created an agent-based model where a Bank agent has randomly assigned variables of “uninsured,” "investments,"and “AFS\_securities” that are collected in a data frame after running. I now want to create a 3D scatter plot with these values on the axes.

How can those variables be accessed if using PlotlyJ? I’m open to using Gadfly or Plots if more efficient.

This is the code for the data collection, then the scatter plot.

```
'''#specify the data to be collected for dataframe
adata = [:totDep, :vul, :health, :uninsured, :investments, :AFS_securities, :social_network]
mdata = [:num_vulnerable_banks, :num_failed_banks]

#initialize a model
testmodel = initialize(; n_banks = 20, n_depositors = 10)

#run the model for 5 time steps
adf, mdf = run!(testmodel, 10; adata, mdata);

#print the results for the model variables
mdf

#prinf the results for the agent variables
adf

#create scatter plot 
df = dataset(DataFrame, "adata")
plot(
    df,
    x=:uninsured, y=:investments, z=:AFS_securties, color=:acolor,
    type="scatter3d", mode="markers"
)'''

```

Thank you.

---

<div class="post-metadata">

**Author:** ![tfranks](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@tfranks](https://discourse.julialang.org/u/tfranks)\
**Post date:** [June 15, 2024, 3:37am UTC](https://discourse.julialang.org/t/agent-based-model-create-scatter-plot-with-agent-variables-from-data-frame/115553/2 "2024-06-15T03:37:14Z")

</div>

Please disregard my question, since I finally realized that “dataset” is a predetermined set of data, not a data frame that I created. I switched to using Gadfly and all is well.

Thank you.
