| 1 | initial version |
Perhaps the problem came from indentation, that I have had to adjust a bit. Try this:
pol = polygon([(0,0), (0,10), (10,10), (0,0)], fill=True, rgbcolor=(0.81,0.81,0.81))
g = plot(x, (0,10), color="blue")
@interact
def _(c=slider(0.01,1, step_size=0.2, default=.5), inac=checkbox(True,"Domaine Inaccessible")):
a = x.subs(solve(-c*x+6==x, x))
h = plot(-c*x+6, (a,6), color="green")
graph = h+g
if inac:
graph += pol
show(graph, aspect_ratio=1, ymin=0,ymax=10)
By the way, the code failed if c=0, as I already pointed in other question, and the plot didn't keep proportions when checking or unchecking inac. I've modified the code to deal with these problems.
| 2 | No.2 Revision |
Perhaps the problem came from indentation, that I have had to adjust a bit. Try this:
pol = polygon([(0,0), (0,10), (10,10), (0,0)], fill=True, rgbcolor=(0.81,0.81,0.81))
g = plot(x, (0,10), color="blue")
@interact
def _(c=slider(0.01,1, step_size=0.2, default=.5), inac=checkbox(True,"Domaine Inaccessible")):
a = x.subs(solve(-c*x+6==x, x))
h = plot(-c*x+6, (a,6), color="green")
graph = h+g
if inac:
graph += pol
show(graph, aspect_ratio=1, ymin=0,ymax=10)
By the way, the code failed if c=0, as I already pointed in other question, and the plot didn't keep proportions when checking or unchecking inac. I've modified the code to deal with these problems.
| 3 | No.3 Revision |
Perhaps the problem came from indentation, that I have had to adjust a bit. Try this:
pol = polygon([(0,0), (0,10), (10,10), (0,0)], fill=True, rgbcolor=(0.81,0.81,0.81))
g = plot(x, (0,10), color="blue")
@interact
def _(c=slider(0.01,1, step_size=0.2, default=.5),
inac=checkbox(True,"Domaine Inaccessible")):
a = x.subs(solve(-c*x+6==x, x))
h = plot(-c*x+6, (a,6), color="green")
graph = h+g
if inac:
graph += pol
show(graph, aspect_ratio=1, ymin=0,ymax=10)
By the way, the code failed if c=0, as I already pointed in other question, and the plot didn't keep proportions when checking or unchecking inac. I've modified the code to deal with these problems.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.