# Possible to use panda3d for plot data

I know that there are libraries specialized in python like matpliltib or vispy but can we do it with panda3D? can we create 2D/3D graphs?
my question is about the scale, how to represent in panda 1 unit?
1 unit is for example 1 mile/kilometer or 1L, 1M^3…

It’s probably fairly easily possible to create a plotting application in Panda3D either using a shader or by drawing lines using LineNodePath or LineSegs.

The common convention for units is that 1 panda unit corresponds to 1 metre, although theoretically you can make it anything you like.

thank you rdb

i see LineNodePathc and it’s very interesting, but seg not work for me
why my seg not draw ?

``````import sys
from direct.showbase.ShowBase import ShowBase
from pandac.PandaModules import *
from direct.directtools.DirectGeometry import LineNodePath

class Application(ShowBase):

def __init__(self):
ShowBase.__init__(self)

l = LineNodePath(render2d,'box',4,VBase4(1,0,0,1))
p1 = (-.5,-.5,0)
p2 = (-.5,.5,0)
p3 = (.5,.5,0)
p4 = (.5,-.5,0)
l.drawLines([[p1,p2],[p2,p3],[p3,p4],[p4,p1]])
l.create()

ls = LineSegs()
ls.setThickness(10)

# X axis
ls.setColor(1.0, 0.0, 0.0, 1.0)
ls.moveTo(0.0, 0.0, 0.0)
ls.drawTo(1.0, 0.0, 0.0)

# Y axis
ls.setColor(0.0, 1.0, 0.0, 1.0)
ls.moveTo(0.0,0.0,0.0)
ls.drawTo(0.0, 1.0, 0.0)

# Z axis
ls.setColor(0.0, 0.0, 1.0, 1.0)
ls.moveTo(0.0,0.0,0.0)
ls.drawTo(0.0, 0.0, 1.0)

ls.create()

segs = LineSegs( )
segs.setThickness( 2.0 )
segs.setColor( Vec4(1,1,0,1) )
segs.create( )

Application().run()``````

For 2D graphs, you can have the library create an image that you upload to the GPU to use as a texture. This may also be possible with 3D graphs and 3D textures.

You need to actually place your LineSegs in the scene graph. The `create()` function returns a node:

``````node = ls.create()
render2d.attachNewNode(node)
``````
1 Like

thank’s rdb it’s work !