Creating a 2D plot via Python API
-
Hello, i am trying to generate 2D plots with python API. The code i use is:
inputs = [em_sensor_extractor.Outputs["EM E(x,y,z,f0)"]]
plot_viewer = analysis.viewers.PlotViewer(inputs=inputs)
plot_viewer.Name = "2D Line Extraction"
plot_viewer.Plotter.Decibel = True
plot_viewer.Plotter.DbRef = 487.989753241
plot_viewer.UpdateAttributes()
document.AllAlgorithms.Add(plot_viewer)When i run this code the program doesn't recognize the input connection. Any idea what is wrong with the code? Furthermore i would like the 2D plot mode to be temporal but i can't find the corresponding functions in the API library. Thank you in advance!
-
Hi, you get an error because your input is a 3D field (EM E(x,y,z,f0)) and this viewer expects 1D data (e.g. E as a function of x).
To address this, you can use the 1D Field Filter (under Field Tools in the GUI) to first extract one-dimensional data out of your 3D field, and then connect the Plot viewer. Do it first in the GUI, then use To-Python function in the context menu to create your script.I hope this helps.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login