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.Mon, 19 Jul 2021 22:54:23 +0200I want to display the origin on the graph.https://ask.sagemath.org/question/58027/i-want-to-display-the-origin-on-the-graph/I'm displaying the graph of a function as follows:
d = 2
n = 1
psi(x) = sqrt(2.0/d)*sin(n*pi*x/d)
graph = plot(abs(psi(x))^2, 0, d, figsize=5, axes_labels=['$x$', '$|\psi_{1}(x)|^2$'])
graph.show()
I want to display "o" at the origin. Is there no choice but to display it in text as shown below?
text('o', (-1, -1))
Fri, 16 Jul 2021 04:35:02 +0200https://ask.sagemath.org/question/58027/i-want-to-display-the-origin-on-the-graph/Answer by tmonteil for <p>I'm displaying the graph of a function as follows:</p>
<pre><code>d = 2
n = 1
psi(x) = sqrt(2.0/d)*sin(n*pi*x/d)
graph = plot(abs(psi(x))^2, 0, d, figsize=5, axes_labels=['$x$', '$|\psi_{1}(x)|^2$'])
graph.show()
</code></pre>
<p>I want to display "o" at the origin. Is there no choice but to display it in text as shown below?</p>
<p> text('o', (-1, -1))</p>
https://ask.sagemath.org/question/58027/i-want-to-display-the-origin-on-the-graph/?answer=58032#post-id-58032Could you please make your question more precise ? The origin is located at the intersection of the axes:
sage: graph + arrow2d((-0.4,-0.4),(-0.02,-0.02), color='red')
If you want to add a point at the origin, you can do:
sage: graph + point2d((0,0), size=50, color='black')
**EDIT** as shown as before, you can add graphics together, including the one produced by `text`:
sage: graph + text('o', (-1, -1))
Launched png viewer for Graphics object consisting of 2 graphics primitives
Of course, you can adapt:
sage: graph + text('0', (-0.1, -0.05), color='black')
Launched png viewer for Graphics object consisting of 2 graphics primitivesFri, 16 Jul 2021 11:00:05 +0200https://ask.sagemath.org/question/58027/i-want-to-display-the-origin-on-the-graph/?answer=58032#post-id-58032Comment by tmonteil for <p>Could you please make your question more precise ? The origin is located at the intersection of the axes:</p>
<pre><code>sage: graph + arrow2d((-0.4,-0.4),(-0.02,-0.02), color='red')
</code></pre>
<p>If you want to add a point at the origin, you can do:</p>
<pre><code>sage: graph + point2d((0,0), size=50, color='black')
</code></pre>
<p><strong>EDIT</strong> as shown as before, you can add graphics together, including the one produced by <code>text</code>:</p>
<pre><code>sage: graph + text('o', (-1, -1))
Launched png viewer for Graphics object consisting of 2 graphics primitives
</code></pre>
<p>Of course, you can adapt:</p>
<pre><code>sage: graph + text('0', (-0.1, -0.05), color='black')
Launched png viewer for Graphics object consisting of 2 graphics primitives
</code></pre>
https://ask.sagemath.org/question/58027/i-want-to-display-the-origin-on-the-graph/?comment=58056#post-id-58056I edited my answer.Mon, 19 Jul 2021 22:54:23 +0200https://ask.sagemath.org/question/58027/i-want-to-display-the-origin-on-the-graph/?comment=58056#post-id-58056Comment by fukui for <p>Could you please make your question more precise ? The origin is located at the intersection of the axes:</p>
<pre><code>sage: graph + arrow2d((-0.4,-0.4),(-0.02,-0.02), color='red')
</code></pre>
<p>If you want to add a point at the origin, you can do:</p>
<pre><code>sage: graph + point2d((0,0), size=50, color='black')
</code></pre>
<p><strong>EDIT</strong> as shown as before, you can add graphics together, including the one produced by <code>text</code>:</p>
<pre><code>sage: graph + text('o', (-1, -1))
Launched png viewer for Graphics object consisting of 2 graphics primitives
</code></pre>
<p>Of course, you can adapt:</p>
<pre><code>sage: graph + text('0', (-0.1, -0.05), color='black')
Launched png viewer for Graphics object consisting of 2 graphics primitives
</code></pre>
https://ask.sagemath.org/question/58027/i-want-to-display-the-origin-on-the-graph/?comment=58050#post-id-58050I'm sorry for the vague question. I have corrected the question, so please answer again if you like.Mon, 19 Jul 2021 03:27:06 +0200https://ask.sagemath.org/question/58027/i-want-to-display-the-origin-on-the-graph/?comment=58050#post-id-58050