Ask Your Question
2

Clipping a 2D plot

asked 2022-09-21 13:56:06 +0100

updated 2022-09-21 14:12:16 +0100

tmonteil gravatar image

Dear all,

Best is a small example:

def fC(p):
    return([p[0]/(p[0]+2), (p[1]+1)/(p[0]+2)])

def actOnD(Dom, nbsteps, myz):
    DomainfC = list(map(fC, Dom))
    acolor = Color(0, (20+90*nbsteps)/255, 150/255) 
    ToPlot = polygon(Dom, color = acolor, zorder = myz)
    if nbsteps > 0:
        DomainfC = list(map(fC, Dom))
        ToPlot += actOnD(DomainfC, nbsteps-1, myz+1)
    return(ToPlot)

actOnD( [[0,0], [0,1], [1,1], [1,0]], 3, 1)

And I would like to show only the plot within a smaller square than the unit one. It seems add_conditions works for parametric plot (though I did not find the documentatin for that, only posts). Many thanks for your lights on that!

Best, Olivier

edit retag flag offensive close merge delete

Comments

To make a block of code, the syntax is to indent by 4 spaces, which you can do by using the 101010 button.

tmonteil gravatar imagetmonteil ( 2022-09-21 14:13:11 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-09-21 14:31:44 +0100

tmonteil gravatar image

updated 2022-09-21 14:34:16 +0100

The trick is to give a name to the Sage object actOnD( [[0,0], [0,1], [1,1], [1,0]], 3, 1) (which is a plot):

sage: P = actOnD( [[0,0], [0,1], [1,1], [1,0]], 3, 1)

Then, you can have a look at its available methods:

sage: P.<tab>

You can see that there is a show option with tons of options:

sage: P.show?

For example, you can set :

sage: P.show(xmax=0.4, ymin=0.3, aspect_ratio=1)
edit flag offensive delete link more

Comments

Many thanks for all that! I had misinterpreted the meaning of xmax, xmin, ymax, ymin family :/ Best, O.

Olivier R. gravatar imageOlivier R. ( 2022-09-22 09:26:22 +0100 )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

Stats

Asked: 2022-09-21 13:56:06 +0100

Seen: 183 times

Last updated: Sep 21 '22