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, 17 Jan 2019 20:19:37 +0100show all view with same x size of Hanoi's Towershttps://ask.sagemath.org/question/45084/show-all-view-with-same-x-size-of-hanois-towers/
Hi
I did this little program to visualize all Hanoi's Towers steps in Jupyter Notebook sagemath 8.4 ,W10.
why my x-axis is not always the same width size in each view?
figsize=[figSizeXmax,figSizeYmax] does not seem to work.
how can I manage to get the same x length for each graph ?
[Code On Cocalc.com](https://cocalc.com/projects/9c478dc8-084a-43b6-aedc-e027b42adfa8/files/HanoiTower.ipynb?session=default)ortolljThu, 17 Jan 2019 20:19:37 +0100https://ask.sagemath.org/question/45084/Getting convex hull of a set of points and plotting the polygonhttps://ask.sagemath.org/question/33548/getting-convex-hull-of-a-set-of-points-and-plotting-the-polygon/I'm using sagemath cloud.
I'm trying to get the convex hull of a finite set of points, then plotting the polygon. If I just plot the polygon with the vertices directly, I don't get the vertices in the right order to make up a convex polygon (plots edges joining the wrong points). Then I found out about cyclic_sort_vertices_2d which I thought would sort the vertices into the right order, but that's giving me errors. I don't understand the meaning of the errors. Appreciate any help.
here's the relevant code:
hull = Polyhedron(vertices=thePoints);
hull.vertices();
cyclic_sort_vertices_2d(hull.vertices());
And I have this import line at the top of my code for cyclic sort:
from sage.geometry.polyhedron.plot import cyclic_sort_vertices_2d;
Here's my output:
(A vertex at (9464.0, 10816.0), A vertex at (8736.0, 7735.0), A vertex at (7904.0, 8736.0), A vertex at (11088.0, 5607.0), A vertex at (15552.0, 6480.0), A vertex at (8160.0, 9248.0), A vertex at (8568.0, 9792.0), A vertex at (11076.0, 10140.0), A vertex at (12852.0, 5355.0))
And errors:
Error in lines 28-30
Traceback (most recent call last):
File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in <module>
File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/geometry/polyhedron/plot.py", line 245, in cyclic_sort_vertices_2d
adjacency_matrix = Vlist[0].polyhedron().vertex_adjacency_matrix()
File "sage/misc/cachefunc.pyx", line 2215, in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (/projects/sage/sage-6.10/src/build/cythonized/sage/misc/cachefunc.c:14346)
self.cache = f(self._instance)
File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/geometry/polyhedron/base.py", line 1847, in vertex_adjacency_matrix
return self._vertex_adjacency_matrix()
File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/geometry/polyhedron/base.py", line 312, in _vertex_adjacency_matrix
face_lattice = self.face_lattice()
File "sage/misc/cachefunc.pyx", line 2215, in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (/projects/sage/sage-6.10/src/build/cythonized/sage/misc/cachefunc.c:14346)
self.cache = f(self._instance)
File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/geometry/polyhedron/base.py", line 3172, in face_lattice
face_constructor=face_constructor, required_atoms=atoms_vertices)
File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/geometry/hasse_diagram.py", line 182, in Hasse_diagram_from_incidences
for coatom, atoms in enumerate(coatom_to_atoms)]
KeyError: (frozenset([]), frozenset([0]))ameetnsharmaThu, 26 May 2016 05:45:37 +0200https://ask.sagemath.org/question/33548/Integration Over Polygonshttps://ask.sagemath.org/question/35210/integration-over-polygons/I'm looking for an open source alternative to Mathematica that provides an easy way to integrate functions over polygons. In Mathematica I can define a polygon R and integrate some function f(x,y) over it with a single command without having to determine the bounds of integration on x and y:
Integrate[f(x,y),{x,y}∈R]
Is it possible to do this type of integration in Sage? The polygons I need to integrate over have hundreds of vertices, so doing it piece-wise is not an option.mhaechreFri, 21 Oct 2016 15:48:39 +0200https://ask.sagemath.org/question/35210/how to connect 2D polygons and show in 3D?https://ask.sagemath.org/question/29406/how-to-connect-2d-polygons-and-show-in-3d/ I'm very much a sage newbie so bear with me all! I'd like to learn how to arbitrarily connect regular 2D polygons together (as in a tesselation or partial polyhedral surface) and display that in 3D.
Thank you,
Chris Hoffmanchoff723Sat, 05 Sep 2015 18:25:18 +0200https://ask.sagemath.org/question/29406/polygon plot does not scale wellhttps://ask.sagemath.org/question/28763/polygon-plot-does-not-scale-well/Hi,
I'm trying to plot several polygons in one plot (with plot1+plot2+...). Strangly, for very different side length, the plot becomes more of a line instead of a rectangle. I tried the following code on SMC and locally:
hp=0.019
qscale=hp
polygon2d([[0.5-0.5,hp/2-qscale*0.05],[0.5+0.5,hp/2-qscale*0.05],[0.5+0.5,hp/2+qscale*0.05],[0.5-0.5,hp/2+qscale*0.05]], fill=False, thickness=1, color='blue',ticks=[None,0.0001])
I'd like to upload a picture but you need 60 karma points for that and since my old account belonging to google identity is lost I hope you can recreate the problem. Thanks in advance.
Update:
I wrote a minimal example which shows that the problem appears when the side length are not of the same order of magnitude
for i in [0.1,1,10,100]:
show(polygon2d([[0,0],[0,i],[1,i],[1,0]], fill=false))kafusslThu, 06 Aug 2015 09:36:20 +0200https://ask.sagemath.org/question/28763/How to plot a polygon with distinct colors for border and interior ?https://ask.sagemath.org/question/24600/how-to-plot-a-polygon-with-distinct-colors-for-border-and-interior/ I would like to have a green polygon with black border. I can achieve this by superposing two polygons:
sage: polygon([[0,0],[0,1],[2,1],[1,0]],color='limegreen',fill=True)+polygon([[0,0],[0,1],[2,1],[1,0]],color='black',fill=False)
Is it possible to do that with one polygon ?FrédéricCThu, 23 Oct 2014 17:37:12 +0200https://ask.sagemath.org/question/24600/How to plot TWO polygons in ONE (2d) graphic?https://ask.sagemath.org/question/10895/how-to-plot-two-polygons-in-one-2d-graphic/Hi!
I'd like to plot some Polygons. Plotting every single polygon works fine, but i want to plot two Polygons in one 2d graphic; with different Colors.
I tried it with polygon() and polygon2d(), but it seems that they can only plot one polygon.
Has anyone here an idea how to solve that?alexmWed, 08 Jan 2014 12:09:50 +0100https://ask.sagemath.org/question/10895/Alpha Values of Points on a Graphhttps://ask.sagemath.org/question/8228/alpha-values-of-points-on-a-graph/Hello,
I'm working on a project that requires the overlapping of many distinct polygons. I have the polygons set up so that they each have a small alpha value so that the overlaps can be seen visually. However, when alpha is very small, it is hard to tell when there is overlap between twelve polygons or thirteen polygons merely by looking at the graph since the transparency difference is so minimal.
Because of this, I would like the program user to be able to specify a point in the plane, and be returned what alpha is equal to. Is this feasible?
Thanks in advance, and I'll be glad to specify any additional details that are necessary.MathStudentThu, 14 Jul 2011 18:04:29 +0200https://ask.sagemath.org/question/8228/Translating a polygon into a fundamental domainhttps://ask.sagemath.org/question/9946/translating-a-polygon-into-a-fundamental-domain/Hello.
I have a polygon (defined, say, via polygon()) that I'm thinking of as filled in with some color. I'd like to understand its image on the quotient of $\mathbb{R}^2$ mod $\mathbb{Z}^2$ by seeing this image in a fundamental domain like the unit square with corners (0,0), (1,0), (0,1), (1,1).
Put differently, I want to translate (by a lattice point) each point in and on the polygon into this square and see what the result looks like.
Is there a reasonable way to do this in SAGE?DrNickWed, 27 Mar 2013 15:48:53 +0100https://ask.sagemath.org/question/9946/How to triangulate polygon with sage?https://ask.sagemath.org/question/8857/how-to-triangulate-polygon-with-sage/If I feed sage a list of vertices, then the polygon() function can create a 2D polygon determined by visiting these edges in order (with self-intersections, repeated edges, holes, etc.).
Does sage have a built-in method to triangulate the resulting polygon? (It appears to me as though this is not the case.)
If not, I would love to see your homemade code to do this.
BillThu, 05 Apr 2012 01:56:02 +0200https://ask.sagemath.org/question/8857/