Opened 8 years ago

Last modified 4 months ago

#14995 new enhancement

Control subticks in 2d plot

Reported by: kcrisman Owned by:
Priority: minor Milestone: sage-9.4
Component: graphics Keywords:
Cc: kcrisman, slelievre Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by slelievre)

In Ask Sage question 691, the very reasonable question of controlling subticks was asked. Meanwhile, Mark Edgington has implemented this!

Here is a description, from the Ask Sage question and answer, of the new functionality:

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, 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

This was made available, as based on Sage 5.10, on bitbucket.

A branch would be needed, with doctests. Some of the stuff on that branch is also for other issues like #8478.

The bitbucket repo is gone, but archived at Software Heritage.

Change History (6)

comment:1 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:2 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:3 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:4 Changed 8 months ago by slelievre

  • Cc kcrisman slelievre added
  • Description modified (diff)
  • Milestone changed from sage-6.4 to sage-9.3

Updating ticket description with Software Heritage link.

Hoping this can be revived.

comment:5 Changed 5 months ago by mkoeppe

  • Milestone changed from sage-9.3 to sage-9.4

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

comment:6 Changed 4 months ago by gh-goebbe

Not sure if this is really relevant for this specific ticket. The following code can be used to get some control about the appearance of the major or minor ticks:

import matplotlib
from pylab import figure, show
matplotlib.rcParams.update({'xtick.major.size':4})   #length
matplotlib.rcParams.update({'ytick.major.size':4})   #length
matplotlib.rcParams.update({'xtick.minor.size':2})   #length
matplotlib.rcParams.update({'ytick.minor.size':0})   #length 0 = no minor ticks on y-axis
matplotlib.rcParams.update({'lines.markeredgewidth':2})  #width of ticks
matplotlib.rcParams.update({'lines.markersize':6})       #size of ticks

However, implementing fine grained control, may be beyond the scope of this ticket.

Currently (Sage 9.2) None is used if the major ticks on an axis are NOT changed. If ticks should not be shown this is used: ticks=[[],[]]) Note that this is different from what is proposed in the description of this ticket for minor_ticks.

Last edited 4 months ago by gh-goebbe (previous) (diff)
Note: See TracTickets for help on using tickets.