Ask Your Question

polygon plot does not scale well

asked 2015-08-06 02:36:20 -0500

kafussl gravatar image

updated 2015-08-07 00:32:20 -0500


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:

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.


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))
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-08-06 11:41:56 -0500

tmonteil gravatar image

To specify the ratio between the axes, you can use the aspect_ratio option.

In your first example:

sage: 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], aspect_ratio=500)

In your second example:

sage: for i in [0.1,1,10,100]:
....:     show(polygon2d([[0,0],[0,i],[1,i],[1,0]], fill=false), aspect_ratio=1/i)
edit flag offensive delete link more


Works like a charm. Thank you.

kafussl gravatar imagekafussl ( 2015-08-06 23:45:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-08-06 02:36:20 -0500

Seen: 43 times

Last updated: Aug 07 '15