Hi (again )
I’m trying to plot values with matplotlib through hops.
When working with ITEM or LIST as HopsParamAccess, it works fine. (plotting a single list of values at most, therefore one polyline on the graph)
When trying to plot multiple lines on a single graph in matplotlib, a simple loop calling the plt.plot() for all the list in the main list works fine.
But here, it seems to only access to one of the lists I input inside Grasshopper (the list corresponding to the first branch). It displays 1 polyline in 1 graph.
The code bellow WON’T work, but is the way I thought it would.
The error here happens at the for loop, because the function seems to receive a branch at a call. The function seems to be called n number of time (for the n number of branches).
@hops.component( "/multi_plot", name="Multiple plots", nickname="Multi_plot", description="Tries to plot multiple lists into one graph using Matplotlib", inputs=[ hs.HopsNumber("Numbers", "N", "Datatree to plot", hs.HopsParamAccess.LIST), hs.HopsBoolean("Plot", "P", "Plot me") ], outputs= ) def multi_plotter(multiple_list, show): if show: for elem in multiple_list: #acces all lists at once??? plt.plot(range(len(elem)), elem) plt.show()
I’ve tried with hs.HopsParamAccess.TREE too, but that one seems to work less than the .LIST
I went on that part of the forum already, but didn’t find the answer to my problem…
Is it possible to call the function once and get all the branches inside at once?
Am I doing something wrong or missing something? Is there a workaround?
Thank you very much in advance for any replies