An error occurs in omni.ui.plot.set_data: Plot data: unknown argument

An error occurs in omni.ui.plot.set_data: Plot data: unknown argument

Sequence of the work

  1. Create a list of 60 items where all arguments are 0.0
  2. Define an empty omni.ui.plot
  3. Define omni.ui.plot with arguments
  4. Defines an asynchronous function

This is the content of the asynchronous function

4-1) Get value from database
4-2) Append data to the list
4-3) Slice the list into 60 pieces
4-4) Execute set_data with a list as argument

this is my code

import omni.ui as ui
import asyncio = [for 0.0 in range(60)]
self.plot = ui.Plot()
self.plot = ui.Plot(ui.Type.LINE, 0.0, 3.0, *, width=500, height=180, style={"color": cl("#F4A445"), "margin": 5})


async def get_value(self):
    while True:
        self.db.get_value() <- this is function that get value from database =[-60:]
        self.plot.set_data(* <- An error occurred in this part

    await asyncio.sleep(5)

There are actually 20 graphs, but I only wrote one in the code
The initial execution goes without a problem,
but an error occurs when set_data is executed when the next data is updated
If set_data is executed while the contents of the list remain unchanged, no error occurs

Does anyone know what the problem is?

In my opinion, when using a graph in widget form, an error occurs if visibility is off. Is this by design?

I would recommend taking a look at this repository on how to set plot data.

Using asyncio.sleep() can also hang the UI in Omniverse, that line of code will also never be reached since it is outside your loop which will always be true.

1 Like

Have you solved this @anmin621 ?

Yes. I solved the problem.
When fetching data from the database,
sometimes data of a different type was fetched,
which was fixed by exception handling.
@ edsonbffilho