Ticket #11500 (new defect)
Problem with accumulating 3D plots over a parameter
| Reported by: | travis | Owned by: | jason, was |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-5.10 |
| Component: | graphics | Keywords: | plot3d |
| Cc: | kcrisman | Work issues: | |
| Report Upstream: | N/A | Reviewers: | |
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description (last modified by travis) (diff)
When creating several layers that interpolate between two surfaces, only one layer is output when accumulating the layers via a loop. No problem if the layers are explicitly coded.
In the looped version, it appears that the plot3d commands are only executed at show() time and therefore only use the final value of the loop parameter. All of the layers are created on top of each other at that final parameter value.
This works:
P += plot3d(lambda x,y: H(x,y,tiers[2]/10),(x,-1,1),(y,-1,1),opacity=0.2)
P += plot3d(lambda x,y: H(x,y,tiers[5]/10),(x,-1,1),(y,-1,1),opacity=0.2)
P += plot3d(lambda x,y: H(x,y,tiers[8]/10),(x,-1,1),(y,-1,1),opacity=0.2)
show(P)
This does not:
for r in ratios:
P += plot3d(lambda x,y: H(x,y,r),(x,-1,1),(y,-1,1),opacity=0.2) # layer
show(P)
Example worksheet is attached.
Attachments
Change History
comment:2 Changed 2 years ago by kcrisman
John, try to copy a minimal example with code so that people don't have to upload it to look at this ticket :) Thanks for getting the spelling right :)
comment:3 Changed 2 years ago by jason
I don't think there is any guarantee that the function is actually executed when the plot3d command is called, is there? You are exposing this because the lambda function does not create a new scope. If instead you use a def function instead of a lambda function, things should work fine.
I agree that it is confusing. I'm trying to decide if it is "wrong".
I've published this worksheet here: http://sagenb.org/home/pub/2823/

