vedo icon indicating copy to clipboard operation
vedo copied to clipboard

Axis disappear when using multiple plots

Open leon-vv opened this issue 1 year ago • 2 comments

Hi!

First of all thanks for creating this great piece of software!

I encountered some behavior which might be a bug. Please consider the code and the screenshots below

Case 1

from vedo import *

plt1 = Plotter(axes=1)
plt1 += Cone()
plt1.show()

plt2 = Plotter(axes=1)
plt2 += Cone()
plt2.show()

Both plots come out correctly as follows: Screenshot from 2024-11-20 21-59-04

Case 2

from vedo import *

plt1 = plotter(axes=1)
plt1 += cone()

plt2 = plotter(axes=1)
plt2 += cone()

plt1.show()
plt2.show()

In the second case the first plot loses its axis: Screenshot from 2024-11-20 22-01-57

I had expected the two plotters to be independent. But this does not appear to be the case, which means that the placement of the .show() call matters. Is this a bug?

leon-vv avatar Nov 20 '24 21:11 leon-vv

Hi Leon, thanks for reporting, it looks indeed a bug.. Possible workarounds:

# import vedo
# from vedo import *

# plt1 = Plotter(axes=1)
# plt1 += Cone()

# plt2 = Plotter(axes=1)
# plt2 += Cone()

# plt2.show()
# vedo.plotter_instance = plt1
# plt1.show()


from vedo import *

plt1 = Plotter(interactive=0)
cone1 = Cone().c("red4")
plt1 += [cone1, Axes(cone1)]

plt2 = Plotter(interactive=0, pos=(1000,0))
cone2 = Cone().rotate_y(60).pos([3,2,1])
plt2 += [cone2, Axes(cone2)]

plt1.show()
plt2.show()
plt2.interactive()
Screenshot 2024-11-21 at 00 06 14

marcomusy avatar Nov 20 '24 23:11 marcomusy

Hi @marcomusy, thanks for letting me know it's indeed a bug. I was able to work around this in my library (https://github.com/leon-vv/Traceon) by 'buffering' the elements to be plotted and only add them to the Plotter just before calling .show(). Thanks anyways for maintaining this piece of software

leon-vv avatar Nov 21 '24 18:11 leon-vv