pythonmatplotlibnurbs

How could I draw multiple NURBS curves on the same figure?


I am using NURBS-python, there is a module called VisMPL, which wrapped the NURBS module together with matplotlib. In the manual of NURBS-python, it only introduced how to draw each curve. But I want to draw several curves on the same picture so that I can compare how approximation works. The code is as below. Please help out. Thanks alot!

In matplotlib, there are ways to add one image to another, so I guess for VisMPL, there is also the way, because I am not family with either, I don't know how to get started.

from geomdl import BSpline
from geomdl import fitting
from geomdl.visualization import VisMPL

P=[[0, 0], [0, 1], [1, 1], [1, 0], [1, -1], [0, -1]]
Degree=3
CPN=5

c1=fitting.interpolate_curve(P, Degree)
c1.vis=VisMPL.VisCurve2D()
c1.render()
c2=fitting.approximate_curve(P, Degree, ctrlpts_size=CPN)
c2.vis=VisMPL.VisCurve2D()
c2.render()

Please help on how to get the two curves on the same pic. Thanks.


Solution

  • OK, I solved this problem by myself. I only need to use the container NURBS-Python given to contain all the curves and plot them. the code became:

    from geomdl import BSpline
    from geomdl import fitting
    from geomdl import multi
    from geomdl.visualization import VisMPL
    
    P=[[0, 0], [0, 1], [1, 1], [1, 0], [1, -1], [0, -1]]
    Degree=3
    CPN=5
    
    c1=fitting.interpolate_curve(P, Degree)
    c2=fitting.approximate_curve(P, Degree, ctrlpts_size=CPN)
    c=multi.CurveContainer([c1, c2])
    
    c.vis=VisMPL.VisCurve2D()
    c.render()