ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 09 Nov 2017 14:12:48 -0600Programmatically setting tickshttp://ask.sagemath.org/question/39334/programmatically-setting-ticks/I currently generate an array of plots by something like:
u = var('u')
array = [vector([u, cos(i*u)]) for i in range(0, 3)]
P = [parametric_plot(p, (u, 0, 2*pi)) for p in array]
Then I can set the axes of individual plots by
P[1].axes(False)
I plot it via
g = graphics_array(P)
g.show()
This produces a plot with three graphs where the second graph has no axes. Great.
I can set ticks when showing a plot:
p = P[1]
p.show(ticks=[[0, 2*pi], [p.ymin(), p.ymax()]], tick_formatter=[pi,None])
But I can't seem to find how to set them programmatically as with the axes above. I have tried accessing the underlying matplotlib object by
m = p.matplotlib
I don't see how to set the ticks there.
> Does anyone know how I can set the ticks for plots individually?Mon, 30 Oct 2017 03:59:18 -0500http://ask.sagemath.org/question/39334/programmatically-setting-ticks/Answer by kcrisman for <p>I currently generate an array of plots by something like:</p>
<pre><code>u = var('u')
array = [vector([u, cos(i*u)]) for i in range(0, 3)]
P = [parametric_plot(p, (u, 0, 2*pi)) for p in array]
</code></pre>
<p>Then I can set the axes of individual plots by</p>
<pre><code>P[1].axes(False)
</code></pre>
<p>I plot it via</p>
<pre><code>g = graphics_array(P)
g.show()
</code></pre>
<p>This produces a plot with three graphs where the second graph has no axes. Great.</p>
<p>I can set ticks when showing a plot:</p>
<pre><code>p = P[1]
p.show(ticks=[[0, 2*pi], [p.ymin(), p.ymax()]], tick_formatter=[pi,None])
</code></pre>
<p>But I can't seem to find how to set them programmatically as with the axes above. I have tried accessing the underlying matplotlib object by</p>
<pre><code>m = p.matplotlib
</code></pre>
<p>I don't see how to set the ticks there.</p>
<blockquote>
<p>Does anyone know how I can set the ticks for plots individually?</p>
</blockquote>
http://ask.sagemath.org/question/39334/programmatically-setting-ticks/?answer=39336#post-id-39336Technically, in matplotlib the ticks are an attribute of the shown object, not the object itself. There is something called an `Axes` object to which ticks belong. That said, you can pass the ticks this way:
u = var('u')
array = [vector([u, cos(i*u)]) for i in range(0, 3)]
P = [parametric_plot(array[i], (u, 0, 2*pi),ticks=[[0,i],[0,i]]) for i in range(len(array))]
g = graphics_array(P)
g
but you will see this doesn't give what you want either; only the last one has the custom ticks. The problem is that we haven't found a good way to resolve https://trac.sagemath.org/ticket/10466 or https://trac.sagemath.org/ticket/10657Mon, 30 Oct 2017 09:50:04 -0500http://ask.sagemath.org/question/39334/programmatically-setting-ticks/?answer=39336#post-id-39336Comment by kcrisman for <p>Technically, in matplotlib the ticks are an attribute of the shown object, not the object itself. There is something called an <code>Axes</code> object to which ticks belong. That said, you can pass the ticks this way:</p>
<pre><code>u = var('u')
array = [vector([u, cos(i*u)]) for i in range(0, 3)]
P = [parametric_plot(array[i], (u, 0, 2*pi),ticks=[[0,i],[0,i]]) for i in range(len(array))]
g = graphics_array(P)
g
</code></pre>
<p>but you will see this doesn't give what you want either; only the last one has the custom ticks. The problem is that we haven't found a good way to resolve <a href="https://trac.sagemath.org/ticket/10466">https://trac.sagemath.org/ticket/10466</a> or <a href="https://trac.sagemath.org/ticket/10657">https://trac.sagemath.org/ticket/10657</a></p>
http://ask.sagemath.org/question/39334/programmatically-setting-ticks/?comment=39462#post-id-39462Yeah, sorry we don't have a better answer for this.Thu, 09 Nov 2017 14:12:48 -0600http://ask.sagemath.org/question/39334/programmatically-setting-ticks/?comment=39462#post-id-39462Comment by Paul Bryan for <p>Technically, in matplotlib the ticks are an attribute of the shown object, not the object itself. There is something called an <code>Axes</code> object to which ticks belong. That said, you can pass the ticks this way:</p>
<pre><code>u = var('u')
array = [vector([u, cos(i*u)]) for i in range(0, 3)]
P = [parametric_plot(array[i], (u, 0, 2*pi),ticks=[[0,i],[0,i]]) for i in range(len(array))]
g = graphics_array(P)
g
</code></pre>
<p>but you will see this doesn't give what you want either; only the last one has the custom ticks. The problem is that we haven't found a good way to resolve <a href="https://trac.sagemath.org/ticket/10466">https://trac.sagemath.org/ticket/10466</a> or <a href="https://trac.sagemath.org/ticket/10657">https://trac.sagemath.org/ticket/10657</a></p>
http://ask.sagemath.org/question/39334/programmatically-setting-ticks/?comment=39394#post-id-39394Okay. thanks. Seems like a thorny issue.Mon, 06 Nov 2017 02:25:20 -0600http://ask.sagemath.org/question/39334/programmatically-setting-ticks/?comment=39394#post-id-39394