ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 09 Jul 2015 06:01:37 +0200Showing a Graphic3d objecthttps://ask.sagemath.org/question/27289/showing-a-graphic3d-object/I have some code which is supposed to spit out a 3d picture. However, my output is "Graphics3d Object" which is not exactly what I want.
# list of points
pts = [(0, 0, 0), (1, 0, 0), (1, 1, 0), (1, 1, 1), (2, 1, 1), (2, 2, 1), (2, 2, 2), (3, 2, 2), (3, 3, 2), (3, 3, 3), (4, 3, 3),(4, 4, 3), (4, 4, 4), (5, 4, 4), (5, 5, 4), (5, 5, 5), (6, 5, 5), (6, 6, 5), (6, 6, 6), (7, 6, 6), (7, 7, 6)]
# some red segments
red_segments = [[pts[i],pts[i+1]] for i in range(len(pts)-1) if i%3==0]
# some green segments
green_segments = [[pts[i],pts[i+1]] for i in range(len(pts)-1) if i%3==1]
# some blue segments
blue_segments = [[pts[i],pts[i+1]] for i in range(len(pts)-1) if i%3==2]
# empty graphics object
P=Graphics()
for rs in red_segments:
P += line3d(rs,color='red')
for gs in green_segments:
P += line3d(gs,color='green')
for bs in blue_segments:
P += line3d(bs,color='blue')
P+=point3d(pts,color='black')
P.show()
I am using the Sage math cloud environment if that at all matters. Does anyone have ideas on how to output the actual 3d graphic that I want instead of the actual object? I'm quite new to using Sage so I apologize if this is a naive question.Thu, 09 Jul 2015 05:28:49 +0200https://ask.sagemath.org/question/27289/showing-a-graphic3d-object/Comment by fidbc for <p>I have some code which is supposed to spit out a 3d picture. However, my output is "Graphics3d Object" which is not exactly what I want. </p>
<pre><code># list of points
pts = [(0, 0, 0), (1, 0, 0), (1, 1, 0), (1, 1, 1), (2, 1, 1), (2, 2, 1), (2, 2, 2), (3, 2, 2), (3, 3, 2), (3, 3, 3), (4, 3, 3),(4, 4, 3), (4, 4, 4), (5, 4, 4), (5, 5, 4), (5, 5, 5), (6, 5, 5), (6, 6, 5), (6, 6, 6), (7, 6, 6), (7, 7, 6)]
# some red segments
red_segments = [[pts[i],pts[i+1]] for i in range(len(pts)-1) if i%3==0]
# some green segments
green_segments = [[pts[i],pts[i+1]] for i in range(len(pts)-1) if i%3==1]
# some blue segments
blue_segments = [[pts[i],pts[i+1]] for i in range(len(pts)-1) if i%3==2]
# empty graphics object
P=Graphics()
for rs in red_segments:
P += line3d(rs,color='red')
for gs in green_segments:
P += line3d(gs,color='green')
for bs in blue_segments:
P += line3d(bs,color='blue')
P+=point3d(pts,color='black')
P.show()
</code></pre>
<p>I am using the Sage math cloud environment if that at all matters. Does anyone have ideas on how to output the actual 3d graphic that I want instead of the actual object? I'm quite new to using Sage so I apologize if this is a naive question.</p>
https://ask.sagemath.org/question/27289/showing-a-graphic3d-object/?comment=27291#post-id-27291Hi @Nomly, you can replace the last line by simply `P`. I think that should work. You can check my updated answer [here](https://x0.no/ls6h) too.Thu, 09 Jul 2015 06:01:37 +0200https://ask.sagemath.org/question/27289/showing-a-graphic3d-object/?comment=27291#post-id-27291