Skip to content

create an improved (and encapsulated) tick mark generator #68

@swharden

Description

@swharden

Tick generation in ScottPlot works but has been sub-ideal for quite some time, as noted by several issues: #66, #57, #54, #47, #28, #17, #3, #2, and #1

Creating tick marks for an axis seems like an easy task at first, but there are several tricky parts that make this difficult to implement cleanly, simply, and correctly. Rather than continuing to pile extra functionality onto the current tick module (hacks on top of hacks), let's get this right and demonstrate it working in an isolated class independent of ScottPlot. Once a new (and good) tick generator is working, I can modify ScottPlot to use it.

Programming Problem

A procedural style seems ideal for this task. A good solution will be short, easy to read, and avoid nested loops and if statements as much as possible. This function should probably be developed and tested using a Console Application.

The tick generator should take in:

  • the 4 corners of a plot (units): double x1, double x2, double y1, double y2
  • the width and height of the plot (pixels): int width, int height
  • font and font size (for determining if ticks overlap)
  • an optional manually-defined tick spacing

The tick generator should produce:

  • an array of tick locations for each axis (a double array of actual units)
  • an array of tick labels for each axis (a string array)
  • a double for the multiplier of each axis (to display in the corners)
  • a double for the offset of each axis (to display in the corners)

Visual Representation

image

Misc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions