Opened 10 years ago

Last modified 7 years ago

#11500 new defect

Problem with accumulating 3D plots over a parameter

Reported by: travis Owned by: jason, was
Priority: minor Milestone: sage-6.4
Component: graphics Keywords: plot3d
Cc: kcrisman Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by travis)

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)


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


Example worksheet is attached.

Attachments (1)

Plot3d bug.sws (402.8 KB) - added by travis 10 years ago.

Download all attachments as: .zip

Change History (11)

Changed 10 years ago by travis

comment:1 Changed 10 years ago by travis

  • Cc kcrisman added; krisman removed

comment:2 Changed 10 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 10 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:

comment:4 Changed 10 years ago by jason

Okay, after thinking about it and discussing this with KDC, I think the current behavior is wrong. I agree with kcrisman that the plot3d command should "freeze" the variables by creating a closure (or a fast_callable object) when it stores the function.

comment:5 Changed 10 years ago by travis

  • Description modified (diff)

comment:6 Changed 9 years ago by kcrisman

  • Component changed from notebook to graphics
  • Owner changed from jason, mpatel, was to jason, was

comment:7 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:8 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:9 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:10 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4
Note: See TracTickets for help on using tickets.