ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 07 Jan 2020 21:58:20 +0100inset() and multi_graphics() are not definedhttps://ask.sagemath.org/question/49410/inset-and-multi_graphics-are-not-defined/ Hi
I am trying to plot two graphics beside each other, in a way that one of them which is smaller is on the upper left side of the other. I tried to run examples of both inset and multi_graphics on sagemath website. But I receive the error of "AttributeError: 'GraphicsArray' object has no attribute 'inset'" for inset, and the error of "NameError: name 'multi_graphics' is not defined" for multi_graphics.
I put my codes below:
Inset:
------
import matplotlib
G = graphics_array([plot(sin, (0, 2*pi)),plot(cos, (0, 2*pi))])
c = circle((0,0), 1, color='red', thickness=2, frame=True)
G.inset(c)
The error:
Error in lines 6-6
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1191, in execute
flags=compile_flags), namespace, locals)
File "", line 1, in <module>
AttributeError: 'GraphicsArray' object has no attribute 'inset'
multi_graphics:
g1 = plot(sin(x), (x, -10, 10), frame=True)
g2 = EllipticCurve([0,0,1,-1,0]).plot(color='red', thickness=2,axes_labels=['$x$', '$y$']) + text(r"$y^2 + y = x^3 - x$", (1.2, 2), color='red')
g3 = matrix_plot(matrix([[1,3,5,1], [2,4,5,6], [1,3,5,7]]))
G = multi_graphics([(g1, (0.125, 0.65, 0.775, 0.3)),(g2, (0.125, 0.11, 0.4, 0.4)),(g3, (0.55, 0.18, 0.4, 0.3))])
G
The error:
Error in lines 4-4
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1191, in execute
flags=compile_flags), namespace, locals)
File "", line 1, in <module>
NameError: name 'multi_graphics' is not defined
I'm working on CoCalc (SageMathCloud) on its unpaid trial server.
---------------Tue, 07 Jan 2020 16:15:25 +0100https://ask.sagemath.org/question/49410/inset-and-multi_graphics-are-not-defined/Answer by eric_g for <p>Hi
I am trying to plot two graphics beside each other, in a way that one of them which is smaller is on the upper left side of the other. I tried to run examples of both inset and multi_graphics on sagemath website. But I receive the error of "AttributeError: 'GraphicsArray' object has no attribute 'inset'" for inset, and the error of "NameError: name 'multi_graphics' is not defined" for multi_graphics.</p>
<p>I put my codes below:</p>
<h2>Inset:</h2>
<pre><code>import matplotlib
G = graphics_array([plot(sin, (0, 2*pi)),plot(cos, (0, 2*pi))])
c = circle((0,0), 1, color='red', thickness=2, frame=True)
G.inset(c)
</code></pre>
<p>The error:</p>
<pre><code>Error in lines 6-6
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1191, in execute
flags=compile_flags), namespace, locals)
File "", line 1, in <module>
AttributeError: 'GraphicsArray' object has no attribute 'inset'
</code></pre>
<p>multi_graphics:</p>
<pre><code>g1 = plot(sin(x), (x, -10, 10), frame=True)
g2 = EllipticCurve([0,0,1,-1,0]).plot(color='red', thickness=2,axes_labels=['$x$', '$y$']) + text(r"$y^2 + y = x^3 - x$", (1.2, 2), color='red')
g3 = matrix_plot(matrix([[1,3,5,1], [2,4,5,6], [1,3,5,7]]))
G = multi_graphics([(g1, (0.125, 0.65, 0.775, 0.3)),(g2, (0.125, 0.11, 0.4, 0.4)),(g3, (0.55, 0.18, 0.4, 0.3))])
G
</code></pre>
<p>The error:</p>
<pre><code>Error in lines 4-4
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1191, in execute
flags=compile_flags), namespace, locals)
File "", line 1, in <module>
NameError: name 'multi_graphics' is not defined
</code></pre>
<p>I'm working on CoCalc (SageMathCloud) on its unpaid trial server.</p>
<hr>
https://ask.sagemath.org/question/49410/inset-and-multi_graphics-are-not-defined/?answer=49415#post-id-49415You are probably using an old version of SageMath in CoCalc. The functions `inset()` and `multi_graphics()` have been introduced in SageMath 9.0 (released on 1 January 2020). In the menu of the Jupyter notebook, do Kernel -> Change kernel and select "SageMath 9.0". Tue, 07 Jan 2020 17:49:37 +0100https://ask.sagemath.org/question/49410/inset-and-multi_graphics-are-not-defined/?answer=49415#post-id-49415Comment by ssss for <p>You are probably using an old version of SageMath in CoCalc. The functions <code>inset()</code> and <code>multi_graphics()</code> have been introduced in SageMath 9.0 (released on 1 January 2020). In the menu of the Jupyter notebook, do Kernel -> Change kernel and select "SageMath 9.0". </p>
https://ask.sagemath.org/question/49410/inset-and-multi_graphics-are-not-defined/?comment=49423#post-id-49423Yes, you are right. Thanks. Can you guide me how I can change sage worksheet kernel (*.sagews)?
Since the way you mentioned is for Jupyter (*.ipynb)Tue, 07 Jan 2020 19:35:10 +0100https://ask.sagemath.org/question/49410/inset-and-multi_graphics-are-not-defined/?comment=49423#post-id-49423Comment by eric_g for <p>You are probably using an old version of SageMath in CoCalc. The functions <code>inset()</code> and <code>multi_graphics()</code> have been introduced in SageMath 9.0 (released on 1 January 2020). In the menu of the Jupyter notebook, do Kernel -> Change kernel and select "SageMath 9.0". </p>
https://ask.sagemath.org/question/49410/inset-and-multi_graphics-are-not-defined/?comment=49425#post-id-49425For Sage worksheets, this does not seem to be easily feasible. Please ask the question to the [CoCalc forum](https://groups.google.com/forum/?fromgroups#!forum/cocalc).Tue, 07 Jan 2020 19:52:34 +0100https://ask.sagemath.org/question/49410/inset-and-multi_graphics-are-not-defined/?comment=49425#post-id-49425Comment by ssss for <p>You are probably using an old version of SageMath in CoCalc. The functions <code>inset()</code> and <code>multi_graphics()</code> have been introduced in SageMath 9.0 (released on 1 January 2020). In the menu of the Jupyter notebook, do Kernel -> Change kernel and select "SageMath 9.0". </p>
https://ask.sagemath.org/question/49410/inset-and-multi_graphics-are-not-defined/?comment=49427#post-id-49427@eric_g ThanksTue, 07 Jan 2020 21:58:20 +0100https://ask.sagemath.org/question/49410/inset-and-multi_graphics-are-not-defined/?comment=49427#post-id-49427