Giter Club home page Giter Club logo

plotkit's Introduction

PlotKit

CocoaPods Compatible Carthage Compatible

Plots made easy.

PlotKit Plot

Features

  • 2D line and scatter plots
  • Multiple axes
  • Custom tick marks

Usage

To start using PlotKit quickly use the plotPoints helper function. It takes a list of points and returns a view that you can use in your app:

import PlotKit

// Generate some data to plot
let count = 1024
let t = (0..<count).map({ 2*M_PI * Double($0) / Double(count-1) })
let y = t.map({ sin($0) })

// Create a PlotView
let plotView1 = plotPoints((0..<count).map{ Point(x: t[$0], y: y[$0]) }, hTicks: .fit(6), vTicks: .fit(4))

Multiple point sets

You can have multiple curves or scatter plots in the same PlotView.

let plotView = PlotView()

let pointSet1 = PointSet(values: values1)
pointSet1.pointType = .disk(radius: 2)
pointSet2.pointColor = .red
pointSet1.lineColor = nil
plotView.addPointSet(pointSet1)

let pointSet2 = PointSet(values: values2)
pointSet2.pointType = .none
pointSet2.lineColor = .blue
plotView.addPointSet(pointSet2)

Axes

You can customize your plot axes. You can have as many axis lines as you want on the same plot.

let plotView = PlotView()

var xaxis = Axis(orientation: .horizontal, ticks: .fit(5))
xaxis.position = .value(0) 
xaxis.color = .blue
xaxis.labelAttributes = [NSForegroundColorAttributeName: NSColor.blue]
plotView.addAxis(xaxis)

var yaxis = Axis(orientation: .vertical, ticks: .distance(1))
yaxis.lineWidth = 2
plotView.addAxis(yaxis)

You can specify ticks in one of three ways:

  • fit(n): Say how many tick marks you want. PlotKit will space them evenly.
  • distance(d): Say how far appart to place tick marks.
  • list(l): Specify exactly the tick marks you want. This is the most flexible. You get to decide where to put the tick marks and also what their labels, line length and line thickness are.

Using PlotKit with Storyboards

If you want to use a PlotView in a Storyboard add an NSView and then change the class name and module like so


License

PlotKit is available under the MIT license. See the LICENSE file for more info.

plotkit's People

Contributors

alejandro-isaza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

plotkit's Issues

Default axes

It should be easier to create default axes. Right now this is what you need to write:

plotView.addAxis(Axis(orientation: .Horizontal, ticks: .Fit(count: 6)))
plotView.addAxis(Axis(orientation: .Vertical, ticks: .Fit(count: 4)))

Labels

Add ability to place labels in the plot by specifying a title and a location.

Function plots

I want to be able to plot a function (x: Double) -> Double that maps x values to y values, for instance sin(x)

Storyboard Support?

Can't seem to get it to work with storyboards.

Always getting Unknown class PlotView in Interface Builder file at path/.....

Heat map

Add support for rendering 3D data as a heat map.

Log scale

Add support for log-log and log-linear scales.

Parametric plots

I want to be able to use a function (t: Double) -> Point to generate a parametric plot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.