Ask Your Question

subticks in 2d plot

asked 2011-08-03 20:41:52 +0100

anonymous user


How would you control the subticks in a 2d plot?


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

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-07-10 12:46:13 +0100

edgimar gravatar image

updated 2013-07-10 13:54:03 +0100

I've implemented some control over minor-ticks in a branch of sage available here. 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) :

p=plot(5*sin(x/10)*sin(x),(x,0,20*pi))[[0,5*pi,10*pi,15*pi,20*pi],5], minor_ticks=pi,

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
edit flag offensive delete link more


This 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 :)

kcrisman gravatar imagekcrisman ( 2013-07-10 17:59:46 +0100 )edit

This is now and a link to this code has been posted.

kcrisman gravatar imagekcrisman ( 2013-08-02 12:56:34 +0100 )edit

answered 2011-08-03 23:46:54 +0100

kcrisman gravatar image

Looking at the reference manual, it looks like we don't provide an interface to explicitly setting Matplotlib's minor ticks.

Certainly this is possible - see this example, 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 and here for additional references.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-08-03 20:41:52 +0100

Seen: 946 times

Last updated: Jul 10 '13