Skip to content
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Python API
  4. Creating a 2D plot via Python API

Creating a 2D plot via Python API

Scheduled Pinned Locked Moved Python API
2 Posts 2 Posters 1.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gagrafio
    wrote on last edited by gagrafio
    #1

    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!

    1 Reply Last reply
    0
    • SylvainS Offline
      SylvainS Offline
      Sylvain
      ZMT
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0

      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
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Search