Latest 0.0.2
License MIT
Platforms osx 10.10

CocoaPods Compatible
Carthage Compatible

Plots made easy.

PlotKit Plot


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


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 ={ 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 = NSColor.redColor()
pointSet1.lineColor = nil

let pointSet2 = PointSet(values: values2)
pointSet2.pointType = .None
pointSet2.lineColor = NSColor.blueColor()


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 = NSColor.blueColor()
xaxis.labelAttributes = [NSForegroundColorAttributeName: NSColor.blueColor()]

var yaxis = Axis(orientation: .Vertical, ticks: .Distance(1))
yaxis.lineWidth = 2

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.


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

Latest podspec

    "name": "PlotKit",
    "version": "0.0.2",
    "summary": "OS X plotting framework",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Alejandro": "[email protected]"
    "platforms": {
        "osx": "10.10"
    "source": {
        "git": "",
        "tag": "0.0.2"
    "source_files": [

Pin It on Pinterest

Share This