Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Easy way to plot your variables in Unity or export them to python

Discussion in 'ML-Agents' started by Hsgngr, Jun 24, 2020.

  1. Hsgngr

    Hsgngr

    Joined:
    Dec 28, 2015
    Posts:
    61
    Hi, I would like to plot some of the variables that I am using in the simulation. For example onTriggerEnter I am
    increasing a counter. Now I would like to see this counter's change with the time. It is really easy to plot this with Python (having 2 different columns one is for counter other is for time) How can I export this data ?
    This will be a infection graph which is going to look like this:
    upload_2020-6-24_14-31-32.png
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,583
    *sorry missed that this was in ML agents thread -- skip this

    could try some charting plugins,
    https://assetstore.unity.com/?q=chart&orderBy=1
    https://github.com/monitor1394/unity-ugui-XCharts

    or export as .CSV and can read that in python
    https://plotly.com/python/plot-data-from-csv/

    .csv is just a text file, so its easy to write into.

    looks like there is at least one csv export too
    https://assetstore.unity.com/packages/tools/input-management/simpleexport-csv-81514

    some unity compatible tutorial (to write csv)
     
    Last edited: Jun 24, 2020
  3. MrWetsnow

    MrWetsnow

    Joined:
    Jan 5, 2020
    Posts:
    60
  4. Hsgngr

    Hsgngr

    Joined:
    Dec 28, 2015
    Posts:
    61
  5. MrWetsnow

    MrWetsnow

    Joined:
    Jan 5, 2020
    Posts:
    60
    Code (CSharp):
    1. var statsRecorder = Academy.Instance.StatsRecorder;
    2. statsRecorder.Add("MyMetric", 1.0);
    :)

    That's all you need. "MyMetric" will now show up in tensorboard.
     
    ervteng_unity likes this.
  6. OrSimhon

    OrSimhon

    Joined:
    Nov 23, 2020
    Posts:
    16
    In which funtion in the scripts these lines need to be ?
    I tried in the initialize function, and "MyMetric" didnt shown up in tensorboard