Ask Your Question
2

Clipping a 2D plot

asked 2 years ago

updated 2 years ago

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

Preview: (hide)

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 ( 2 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 2 years ago

tmonteil gravatar image

updated 2 years ago

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)
Preview: (hide)
link

Comments

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

Olivier R. gravatar imageOlivier R. ( 2 years ago )

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: 2 years ago

Seen: 203 times

Last updated: Sep 21 '22