qiskit-community / monodromy

Computations in the monodromy polytope for quantum gate sets
Apache License 2.0
17 stars 9 forks source link

In-house rendering #1

Open ecpeterson opened 3 years ago

ecpeterson commented 3 years ago

Currently, our best polytope visualization option is to export a blob of Mathematica code for the user to run. This is not great.

I looked at a couple of python packages that draw polytopes, but I didn't make any headway.

evmckinney9 commented 2 years ago

Here is what I have been using

import matplotlib.pyplot as plt
plt.close()
fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")

from weylchamber import WeylChamber
w = WeylChamber();

total_coord_list = []
for subpoly in reduced_vertices:
    subpoly_coords = [[float(x) for x in coord] for coord in subpoly]
    total_coord_list += subpoly_coords
    w.scatter(*zip(*subpoly_coords))

from scipy.spatial import ConvexHull
pts = np.array(total_coord_list)
hull = ConvexHull(pts)
for s in hull.simplices:
    s = np.append(s, s[0])  # Here we cycle back to the first coordinate
    ax.plot(pts[s, 0], pts[s, 1], pts[s, 2], "r-")

w.render(ax)
%matplotlib widget

image

evmckinney9 commented 1 year ago

Here is my new version on my fork

image

image