ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 02 Aug 2013 05:56:34 -0500subticks in 2d plothttps://ask.sagemath.org/question/8261/subticks-in-2d-plot/How would you control the subticks in a 2d plot?
var('x')
p=plot(5*sin(x/10)*sin(x),(x,0,20*pi))
p.show(ticks=[[0,5*pi,10*pi,15*pi,20*pi],5],tick_formatter="latex")
Gives the labelled ticks exactly where I would like them but I'd like to have unlabelled ticks at every pi value. In particular I'm looking at graphing
+-5sin(x/10) and having some students fill in the plot of the more complicated functionWed, 03 Aug 2011 13:41:52 -0500https://ask.sagemath.org/question/8261/subticks-in-2d-plot/Answer by edgimar for <p>How would you control the subticks in a 2d plot?</p>
<pre><code>var('x')
p=plot(5*sin(x/10)*sin(x),(x,0,20*pi))
p.show(ticks=[[0,5*pi,10*pi,15*pi,20*pi],5],tick_formatter="latex")
</code></pre>
<p>Gives the labelled ticks exactly where I would like them but I'd like to have unlabelled ticks at every pi value. In particular I'm looking at graphing
+-5sin(x/10) and having some students fill in the plot of the more complicated function</p>
https://ask.sagemath.org/question/8261/subticks-in-2d-plot/?answer=15220#post-id-15220I've implemented some control over minor-ticks in a branch of sage available <a href="https://bitbucket.org/edgimar/sage-main">here</a>. Hopefully it (or some improved version of it) will get incorporated into the sage codebase at some point.
Here's an example which should achieve what was sought after by the questioner (except that minor ticks are smaller than major ticks, which may not have been desired) :
var('x')
p=plot(5*sin(x/10)*sin(x),(x,0,20*pi))
p.show(ticks=[[0,5*pi,10*pi,15*pi,20*pi],5], minor_ticks=pi,
tick_formatter="latex")
If the `minor_ticks` option is **not** specified, then minor-tick behavior will follow previous Sage defaults.
If the option **is** specified, then the following examples describe the behavior:
minor_ticks=None, or =[None,None] -- no minor ticks will appear on either x or y axes
minor_ticks=3 -- minor ticks every 3 units on x axis ; Sage defaults on y axis
minor_ticks=[3,None] -- minor ticks every 3 units on x axis ; none on y axis
minor_ticks=[3,[2,7]] -- minor ticks every 3 units on x axis ; at 2 and 7 on y axis
Wed, 10 Jul 2013 05:46:13 -0500https://ask.sagemath.org/question/8261/subticks-in-2d-plot/?answer=15220#post-id-15220Comment by kcrisman for <p>I've implemented some control over minor-ticks in a branch of sage available <a href="https://bitbucket.org/edgimar/sage-main">here</a>. Hopefully it (or some improved version of it) will get incorporated into the sage codebase at some point.</p>
<p>Here's an example which should achieve what was sought after by the questioner (except that minor ticks are smaller than major ticks, which may not have been desired) :</p>
<pre><code>var('x')
p=plot(5*sin(x/10)*sin(x),(x,0,20*pi))
p.show(ticks=[[0,5*pi,10*pi,15*pi,20*pi],5], minor_ticks=pi,
tick_formatter="latex")
</code></pre>
<p>If the <code>minor_ticks</code> option is <strong>not</strong> specified, then minor-tick behavior will follow previous Sage defaults.
If the option <strong>is</strong> specified, then the following examples describe the behavior:</p>
<pre><code>minor_ticks=None, or =[None,None] -- no minor ticks will appear on either x or y axes
minor_ticks=3 -- minor ticks every 3 units on x axis ; Sage defaults on y axis
minor_ticks=[3,None] -- minor ticks every 3 units on x axis ; none on y axis
minor_ticks=[3,[2,7]] -- minor ticks every 3 units on x axis ; at 2 and 7 on y axis
</code></pre>
https://ask.sagemath.org/question/8261/subticks-in-2d-plot/?comment=17306#post-id-17306This looks like it could be very helpful. I think there has already been some work on the refactoring in some graphics tickets, so the entire patch may not be needed in that way. We'll want to have a Trac ticket and so forth for discussing this - do you have a Sage Trac account? If not, you should get one and let's get working on this :)Wed, 10 Jul 2013 10:59:46 -0500https://ask.sagemath.org/question/8261/subticks-in-2d-plot/?comment=17306#post-id-17306Comment by kcrisman for <p>I've implemented some control over minor-ticks in a branch of sage available <a href="https://bitbucket.org/edgimar/sage-main">here</a>. Hopefully it (or some improved version of it) will get incorporated into the sage codebase at some point.</p>
<p>Here's an example which should achieve what was sought after by the questioner (except that minor ticks are smaller than major ticks, which may not have been desired) :</p>
<pre><code>var('x')
p=plot(5*sin(x/10)*sin(x),(x,0,20*pi))
p.show(ticks=[[0,5*pi,10*pi,15*pi,20*pi],5], minor_ticks=pi,
tick_formatter="latex")
</code></pre>
<p>If the <code>minor_ticks</code> option is <strong>not</strong> specified, then minor-tick behavior will follow previous Sage defaults.
If the option <strong>is</strong> specified, then the following examples describe the behavior:</p>
<pre><code>minor_ticks=None, or =[None,None] -- no minor ticks will appear on either x or y axes
minor_ticks=3 -- minor ticks every 3 units on x axis ; Sage defaults on y axis
minor_ticks=[3,None] -- minor ticks every 3 units on x axis ; none on y axis
minor_ticks=[3,[2,7]] -- minor ticks every 3 units on x axis ; at 2 and 7 on y axis
</code></pre>
https://ask.sagemath.org/question/8261/subticks-in-2d-plot/?comment=17196#post-id-17196This is now http://trac.sagemath.org/ticket/14995 and a link to this code has been posted.Fri, 02 Aug 2013 05:56:34 -0500https://ask.sagemath.org/question/8261/subticks-in-2d-plot/?comment=17196#post-id-17196Answer by kcrisman for <p>How would you control the subticks in a 2d plot?</p>
<pre><code>var('x')
p=plot(5*sin(x/10)*sin(x),(x,0,20*pi))
p.show(ticks=[[0,5*pi,10*pi,15*pi,20*pi],5],tick_formatter="latex")
</code></pre>
<p>Gives the labelled ticks exactly where I would like them but I'd like to have unlabelled ticks at every pi value. In particular I'm looking at graphing
+-5sin(x/10) and having some students fill in the plot of the more complicated function</p>
https://ask.sagemath.org/question/8261/subticks-in-2d-plot/?answer=12554#post-id-12554Looking at [the reference manual](http://www.sagemath.org/doc/reference/sage/plot/plot.html), it looks like we don't provide an interface to explicitly setting Matplotlib's minor ticks.
Certainly this is possible - see [this example](http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo1.html#pylab-examples-major-minor-demo1), where it is pretty clear what mpl code does what. We use the same method, but don't really customize. It probably would be nice to wrap.
See also [here](http://stackoverflow.com/questions/6567724/matplotlib-so-log-axis-only-has-minor-tick-mark-labels-at-specified-points-also) and [here](http://matplotlib.sourceforge.net/api/ticker_api.html) for additional references.Wed, 03 Aug 2011 16:46:54 -0500https://ask.sagemath.org/question/8261/subticks-in-2d-plot/?answer=12554#post-id-12554