ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 29 Nov 2016 17:47:24 -0600plotting 3d polytope in R^4http://ask.sagemath.org/question/35704/plotting-3d-polytope-in-r4/ I'm trying to plot the following polytope on the cloud:
P=Polyhedron(vertices=[[0, 1, 0, 4] , [0, 1, 1, 3] , [3, 1, 1, 0] , [3, 1, 0, 1] , [0, 3, 0, 2] , [0, 3, 1, 1] , [1, 0, 0, 4] , [1, 0, 1, 3] , [3, 0, 1, 1] , [3, 0, 0, 2] , [1, 3, 1, 0] , [1, 3, 0, 1]])
P.plot()
This is a polytope living in R^4, but in fact the sum of the coordinates of each vertex is 5, so it is a 3D polytope. In some cases, sage gives me a nice 3D view of how the polytope looks like, but in this case it gives me something that doesn't even looks convex, so it is not the right projection. I would like to know what is going on and try to solve this issue, so I appreciate ideas on how to correct this, and where to look at on the code. Wed, 23 Nov 2016 14:27:10 -0600http://ask.sagemath.org/question/35704/plotting-3d-polytope-in-r4/Comment by EmersonL for <p>I'm trying to plot the following polytope on the cloud:</p>
<pre><code>P=Polyhedron(vertices=[[0, 1, 0, 4] , [0, 1, 1, 3] , [3, 1, 1, 0] , [3, 1, 0, 1] , [0, 3, 0, 2] , [0, 3, 1, 1] , [1, 0, 0, 4] , [1, 0, 1, 3] , [3, 0, 1, 1] , [3, 0, 0, 2] , [1, 3, 1, 0] , [1, 3, 0, 1]])
P.plot()
</code></pre>
<p>This is a polytope living in R^4, but in fact the sum of the coordinates of each vertex is 5, so it is a 3D polytope. In some cases, sage gives me a nice 3D view of how the polytope looks like, but in this case it gives me something that doesn't even looks convex, so it is not the right projection. I would like to know what is going on and try to solve this issue, so I appreciate ideas on how to correct this, and where to look at on the code. </p>
http://ask.sagemath.org/question/35704/plotting-3d-polytope-in-r4/?comment=35804#post-id-35804I tried different projection directions, and always the plot seems to have the same non-convexity issues. I guess there is something wrong with these projections.Tue, 29 Nov 2016 17:47:24 -0600http://ask.sagemath.org/question/35704/plotting-3d-polytope-in-r4/?comment=35804#post-id-35804Comment by fidbc for <p>I'm trying to plot the following polytope on the cloud:</p>
<pre><code>P=Polyhedron(vertices=[[0, 1, 0, 4] , [0, 1, 1, 3] , [3, 1, 1, 0] , [3, 1, 0, 1] , [0, 3, 0, 2] , [0, 3, 1, 1] , [1, 0, 0, 4] , [1, 0, 1, 3] , [3, 0, 1, 1] , [3, 0, 0, 2] , [1, 3, 1, 0] , [1, 3, 0, 1]])
P.plot()
</code></pre>
<p>This is a polytope living in R^4, but in fact the sum of the coordinates of each vertex is 5, so it is a 3D polytope. In some cases, sage gives me a nice 3D view of how the polytope looks like, but in this case it gives me something that doesn't even looks convex, so it is not the right projection. I would like to know what is going on and try to solve this issue, so I appreciate ideas on how to correct this, and where to look at on the code. </p>
http://ask.sagemath.org/question/35704/plotting-3d-polytope-in-r4/?comment=35707#post-id-35707Maybe setting `projection_direction` when calling the [plot](http://doc.sagemath.org/html/en/reference/geometry/sage/geometry/polyhedron/base.html#sage.geometry.polyhedron.base.Polyhedron_base.plot) method could help.Wed, 23 Nov 2016 15:55:18 -0600http://ask.sagemath.org/question/35704/plotting-3d-polytope-in-r4/?comment=35707#post-id-35707Answer by tmonteil for <p>I'm trying to plot the following polytope on the cloud:</p>
<pre><code>P=Polyhedron(vertices=[[0, 1, 0, 4] , [0, 1, 1, 3] , [3, 1, 1, 0] , [3, 1, 0, 1] , [0, 3, 0, 2] , [0, 3, 1, 1] , [1, 0, 0, 4] , [1, 0, 1, 3] , [3, 0, 1, 1] , [3, 0, 0, 2] , [1, 3, 1, 0] , [1, 3, 0, 1]])
P.plot()
</code></pre>
<p>This is a polytope living in R^4, but in fact the sum of the coordinates of each vertex is 5, so it is a 3D polytope. In some cases, sage gives me a nice 3D view of how the polytope looks like, but in this case it gives me something that doesn't even looks convex, so it is not the right projection. I would like to know what is going on and try to solve this issue, so I appreciate ideas on how to correct this, and where to look at on the code. </p>
http://ask.sagemath.org/question/35704/plotting-3d-polytope-in-r4/?answer=35708#post-id-35708You can let your polytope live in its affine hull, which is 3-dimensional:
sage: P.affine_hull().plot()
Wed, 23 Nov 2016 19:01:52 -0600http://ask.sagemath.org/question/35704/plotting-3d-polytope-in-r4/?answer=35708#post-id-35708Comment by EmersonL for <p>You can let your polytope live in its affine hull, which is 3-dimensional:</p>
<pre><code>sage: P.affine_hull().plot()
</code></pre>
http://ask.sagemath.org/question/35704/plotting-3d-polytope-in-r4/?comment=35803#post-id-35803The documentation of affine_hull should be more specific telling what is the output polyhedron, and in which sense it is the same as the original one. As I see, in this example it is a projection to the first 3 coordinates, but it is not similar to the original one, but only affinely equivalent.Tue, 29 Nov 2016 17:45:53 -0600http://ask.sagemath.org/question/35704/plotting-3d-polytope-in-r4/?comment=35803#post-id-35803