Skip to content

Collection support for ScatterPlots #526

@swharden

Description

@swharden

In the past we've discussed what it would take to support plotting more types of data than double[]. @StendProg posted an excellent summary of options in #103 (comment) which led to support for generic types in SignalConst (#100). It may be time to consider adding collection support to scatter plots. David Hary raised this topic in an email today. Here are my thoughts currently:

Usage

List<int> xs = new List<int> {1, 2, 3};
List<double> ys = new List<double> {1.5, 3.0, 4.5};

var plt = new ScottPlot.Plot();
plt.PlotScatter(xs, ys);

Implementation

  • Xs and Ys would become ICollection<T>
  • Scatter plots would convert Xs and Ys to double[] at in the Render and GetLimits methods.
    Generics cant easily be compared (e.g., >), but converting to double[] solves this problem.

Cons

  • Conversion to array takes time. However, Scatter plots are already not performant, and they are intended only for small numbers of data points, so this conversion will be very fast.
  • Xs and Ys must be size-checked on every render. Mismatch would throw errors on render, rather than on instantiation.

Pros

  • Xs and Ys could be different types, such as List<int> and List<float>
  • Xs and Ys could change number of points between renders
  • This change could be made to be non-breaking to the Plot module, with an extra overload to support collections

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