Plotting data is easy, but putting tick marks
(with values) on the horizontal and vertical
axises is harder. Plotting an arbitrary part
of an arbitrary dataset (x and y values) is what
I want to do, generating ticks accordingly.
The function to do this should take as input :
- low : left value
- high : right value of the plot
- density : approximate number of tick marks on the axis
and produce as output :
- list of tick mark positions in the axis' units
- labels (character strings for above)
Tick marks should of course be "rounded", i.e. fall
on the simplest numbers possible.
Example 1
Input :
low = -3.2564
high = 11.926
density = 4
Output :
Tick marks at -3.0, 0.0, 3.0, 6.0, 9.0
Example 2
Input :
low = 10.0017
high = 10.0058
density = 8
Output :
Ticks at 10.002 10.0025 10.003 10.0035 10.004 10.0045 10.005 10.0055
A refinement is to also produce minor, unlabeled ticks between
major (labeled) ticks.
All plotting packages do that for you, but I want to
write my own, to have better control over the final
appearance of the plot.
Any hints, suggestions or methods greatly appreciated !
(with values) on the horizontal and vertical
axises is harder. Plotting an arbitrary part
of an arbitrary dataset (x and y values) is what
I want to do, generating ticks accordingly.
The function to do this should take as input :
- low : left value
- high : right value of the plot
- density : approximate number of tick marks on the axis
and produce as output :
- list of tick mark positions in the axis' units
- labels (character strings for above)
Tick marks should of course be "rounded", i.e. fall
on the simplest numbers possible.
Example 1
Input :
low = -3.2564
high = 11.926
density = 4
Output :
Tick marks at -3.0, 0.0, 3.0, 6.0, 9.0
Example 2
Input :
low = 10.0017
high = 10.0058
density = 8
Output :
Ticks at 10.002 10.0025 10.003 10.0035 10.004 10.0045 10.005 10.0055
A refinement is to also produce minor, unlabeled ticks between
major (labeled) ticks.
All plotting packages do that for you, but I want to
write my own, to have better control over the final
appearance of the plot.
Any hints, suggestions or methods greatly appreciated !