Skip to content
This repository has been archived by the owner on Apr 16, 2018. It is now read-only.

Plot seems to fail #203

Closed
danyill opened this issue Jan 26, 2016 · 3 comments
Closed

Plot seems to fail #203

danyill opened this issue Jan 26, 2016 · 3 comments

Comments

@danyill
Copy link

danyill commented Jan 26, 2016

For: https://cloud.sagemath.com/projects/2a2796e2-e818-4f4b-928f-e111b1bdcf75/files/Cap_Calc_R135_for_mod.sagews

This used to work quite well, now I get errors associated with the plot command:

def simpler_equations_interact(C_val = slider(range(1,100000), default = 1)):
    a=plot([arrow2d(tailpoint=(0, 0), headpoint=CC(eq122_cap(C_val*10**-9)), color='red', legend_label="$V_{R_{1}}$", legend_color='black'),
            arrow2d(tailpoint=(0, 0), headpoint=CC(magang(vnom_val,-120)), color='yellow', legend_label="$V_{Y_{1}}$", legend_color='black'),
            arrow2d(tailpoint=(0, 0), headpoint=CC(magang(vnom_val,-240)), color='blue', legend_label="$V_{B_{1}}$", legend_color='black'),
            arrow2d(tailpoint=(0, 0), headpoint=CC(eq122_cap(C_val*10**-9)+magang(vnom_val,-120)+magang(vnom_val,-240)), color='green', legend_label="$3V_0$", legend_color='black',width=2)],
                legend_label='result phasors',
                legend_color='green',
                title="Changing R phase source impedance, $R_{RS}$ from 1$\Omega$ to 20k$\Omega$ to simulate evolving open-circuit",
                xmin=-190,xmax=190,ymin=-190,ymax=190,
                scale='linear')
    a.show(xmin=-190,ymin=-190,xmax=190,ymax=190)

The error I get is:

Error in lines 1-1
Traceback (most recent call last):
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 1, in <module>
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1055, in _execute_interact
    sage_salvus.interacts[id](vals)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_salvus.py", line 216, in __call__
    self._f(**dict([(k,self._last_vals[k]) for k in self._args]))
  File "", line 11, in simpler_equations_interact
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 705, in wrapper
    return func(*args, **kwds)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 550, in wrapper
    return func(*args, **options)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1310, in plot
    G = _plot(funcs, (xmin, xmax), **kwds)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1467, in _plot
    fillcolor = fillcolor_temp, **options_temp)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 705, in wrapper
    return func(*args, **kwds)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 550, in wrapper
    return func(*args, **options)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1301, in plot
    G = funcs.plot(*args, **original_opts)
TypeError: plot() takes exactly 1 argument (16 given)

I can't see a reason for this. I have looked at the plot help. Has there been a breaking change in the plot command?

I can replicate in a new worksheet with:

b=[arrow2d(tailpoint=(0, 0), headpoint=(1,4), color='red', legend_label="$V_{R_{1}}$", legend_color='black'),
   arrow2d(tailpoint=(0, 0), headpoint=(1,3), color='yellow', legend_label="$V_{Y_{1}}$", legend_color='black'),
   arrow2d(tailpoint=(0, 0), headpoint=(1,2), color='blue', legend_label="$V_{B_{1}}$", legend_color='black'),
   arrow2d(tailpoint=(0, 0), headpoint=(1,1), color='green', legend_label="$3V_0$", legend_color='black',width=2)]
a=plot(b)

which gives the error:

Error in lines 5-5
Traceback (most recent call last):
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 1, in <module>
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 705, in wrapper
    return func(*args, **kwds)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 550, in wrapper
    return func(*args, **options)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1310, in plot
    G = _plot(funcs, (xmin, xmax), **kwds)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1467, in _plot
    fillcolor = fillcolor_temp, **options_temp)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 705, in wrapper
    return func(*args, **kwds)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 550, in wrapper
    return func(*args, **options)
  File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1301, in plot
    G = funcs.plot(*args, **original_opts)
TypeError: plot() takes exactly 1 argument (15 given)

I hope this is not a silly issue...

@williamstein
Copy link
Contributor

You can't do plot([a graphics object, ...]). The plot function takes as input a function (and other parameters), not a graphics object. When you write plot(b) above are you trying to superimpose the four arrows? In that case, do sum(b), like this:

https://cloud.sagemath.com/projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/files/support/2016-01-26-121025-plot-add.sagews

@danyill
Copy link
Author

danyill commented Jan 27, 2016

Thank you - sorry this was a silly question. This did work in SMC not long ago and so I was not sure why the behaviour changed.

@williamstein
Copy link
Contributor

You are definitely write that this work in Sage-6.9 but does not work in Sage-6.10. I don't know why Sage changed this way to no longer allow this construction.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants