{"id":13423648,"url":"https://github.com/KarthikRIyer/swiftplot","last_synced_at":"2025-03-15T17:32:04.173Z","repository":{"id":36450207,"uuid":"185946183","full_name":"KarthikRIyer/swiftplot","owner":"KarthikRIyer","description":"Swift library for Data Visualization :bar_chart:","archived":false,"fork":false,"pushed_at":"2022-06-04T01:49:54.000Z","size":21943,"stargazers_count":403,"open_issues_count":17,"forks_count":40,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-14T14:05:25.156Z","etag":null,"topics":["data-visualization","graph","plots","swift"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KarthikRIyer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-10T08:04:45.000Z","updated_at":"2025-03-09T02:00:47.000Z","dependencies_parsed_at":"2022-07-29T21:10:04.648Z","dependency_job_id":null,"html_url":"https://github.com/KarthikRIyer/swiftplot","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarthikRIyer%2Fswiftplot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarthikRIyer%2Fswiftplot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarthikRIyer%2Fswiftplot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarthikRIyer%2Fswiftplot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KarthikRIyer","download_url":"https://codeload.github.com/KarthikRIyer/swiftplot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243589338,"owners_count":20315471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-visualization","graph","plots","swift"],"created_at":"2024-07-31T00:00:39.737Z","updated_at":"2025-03-15T17:32:04.120Z","avatar_url":"https://github.com/KarthikRIyer.png","language":"C++","readme":"\u003cdiv\u003e\u003cimg src=\"swiftplot.png\" width=\"600\"\u003e\u003c/div\u003e\n\u003cbr\u003e\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\u003cbr\u003e\n\n# Table of contents\n\n  * [Overview](#overview)\n  * [License](#license)\n  * [How to include the library in your package](#how-to-include-the-library-in-your-package)\n  * [How to include the library in your Jupyter Notebook](#how-to-include-the-library-in-your-jupyter-notebook)\n  * [How to setup Docker instance for SwiftPlot](#how-to-setup-docker-instance-for-swiftplot)\n  * [Examples](#examples)\n    * [Simple Line Graph](#simple-line-graph)\n    * [Line Graph with multiple series of data](#line-graph-with-multiple-series-of-data)\n    * [Line Graph with Sub Plots stacked horizontally](#line-graph-with-sub-plots-stacked-horizontally)\n    * [Plot functions using LineGraph](#plot-functions-using-linegraph)\n    * [Using a secondary axis in LineGraph](#using-a-secondary-axis-in-linegraph)\n    * [Displaying plots in Jupyter Notebook](#displaying-plots-in-jupyter-notebook)\n  * [How does this work ?](#how-does-this-work)\n  * [Documentation](#documentation)\n  * [Limitations](#limitations)\n  * [Guidelines for Contributors](#guidelines-for-contributors)\n  * [Credits](#credits)\n\n## Overview\nThe SwiftPlot framework is a cross-platform library that lets you plot graphs natively in Swift.\nThe existing Swift plotting frameworks (such as CorePlot) run only on iOS or Mac.\nThe idea behind SwiftPlot is to create a cross-platform library that runs on iOS, Mac, Linux and Windows.\n\u003c/br\u003e\n\u003c/br\u003e\nSwiftPlot currently uses three rendering backends to generate plots:\n- Anti-Grain Geometry(AGG) C++ rendering library\n- A simple SVG Renderer\n- A Core Graphics renderer with support for macOS, iOS, watchOS and tvOS\n\nTo encode the plots as PNG images it uses the [lodepng](https://github.com/lvandeve/lodepng) library.\n\u003c/br\u003e\nSwiftPlot can also be used in Jupyter Notebooks, with Python interop support for Google Colab.\n\u003c/br\u003e\n\nExamples, demonstrating all the features, have been included with the repository under the `Tests/SwiftPlotTests` directory. To run the examples, clone the repository, and run the `swift test` command from the package directory.\n\nJupyter Notebook examples are under the `Notebooks` directory.\n\nThe resultant images are stored in a directory named  `output`. The `Tests` folder includes a collection of reference images in the `Reference` directory.\n\n\n## License\n\n\u003cb\u003eSwiftPlot\u003c/b\u003e is licensed under `Apache 2.0`. View [license](https://github.com/KarthikRIyer/swiftplot/blob/master/LICENSE)\n\n## How to include the library in your package\nAdd the library to your projects dependencies in the Package.swift file as shown below.\n```swift\ndependencies: [\n        .package(url: \"https://github.com/KarthikRIyer/swiftplot.git\", from: \"2.0.0\")),\n    ],\n```\n\nIn case you get an error saying that a file \u003cb\u003eft2build.h\u003c/b\u003e is not found, you need to install the freetype development package.\n\n\u003cb\u003eLinux\u003c/b\u003e\u003c/br\u003e\n```console\nsudo apt-get install libfreetype6-dev\n```\n\n\u003cb\u003emacOS\u003c/b\u003e\u003c/br\u003e\n```console\nbrew install freetype\n```\n\nIf the above method doesn't work you can also build and install freetype on your own. You can find the source code and build instructions [here](https://www.freetype.org/download.html).\n\n## How to include the library in your Jupyter Notebook\n\nAdd these lines to the first cell:\n```swift\n%install-swiftpm-flags -Xcc -isystem/usr/include/freetype2 -Xswiftc -lfreetype\n%install '.package(url: \"https://github.com/IBM-Swift/BlueCryptor.git\", from: \"1.0.28\")' Cryptor\n%install '.package(url: \"https://github.com/KarthikRIyer/swiftplot\", from: \"2.0.0\")' SwiftPlot AGGRenderer\n```\nIn order to display the generated plot in the notebook, add this line to a new cell:\n```swift\n%include \"EnableJupyterDisplay.swift\"\n```\nIf you wish to display the generated plot in a Google Colab environment, add these lines to a new cell instead:\n```swift\nimport Python\n%include \"EnableIPythonDisplay.swift\"\nfunc display(base64EncodedPNG: String) {\n  let displayImage = Python.import(\"IPython.display\")\n  let codecs = Python.import(\"codecs\")\n  let imageData = codecs.decode(Python.bytes(base64EncodedPNG, encoding: \"utf8\"), encoding: \"base64\")\n  displayImage.Image(data: imageData, format: \"png\").display()\n}\n```\nNote that because Google Colab doesn't natively support Swift libraries that produce rich output, we use Swift's Python interop as a workaround. \n\n## How to setup Docker instance for SwiftPlot\nFor computers running MacOS or Windows, Docker instance is to easy to setup and use `swift-jupyter`. Please refer [SwiftPlot_Docker_setup.md](https://github.com/KarthikRIyer/swiftplot/blob/master/Swiftplot_Docker_setup.md) for setup instructions.\n\n## Examples\nHere are some examples to provide you with a headstart to using this library. Here we will be looking at plots using only the AGGRenderer, but the procedure will remain the same for SVGRenderer.\nTo use the library in your package, include it as a dependency to your target, in the Package.swift file.\n\nMore tests can be found in the [SwiftPlotTests](Tests/SwiftPlotTests) folder.\n\n#### Simple Line Graph\n\n```swift\nimport SwiftPlot\nimport AGGRenderer\n\nlet x:[Float] = [10,100,263,489]\nlet y:[Float] = [10,120,500,800]\n\nvar agg_renderer: AGGRenderer = AGGRenderer()\nvar lineGraph = LineGraph\u003cFloat,Float\u003e(enablePrimaryAxisGrid: true)\nlineGraph.addSeries(x, y, label: \"Plot 1\", color: .lightBlue)\nlineGraph.plotTitle.title = \"SINGLE SERIES\"\nlineGraph.plotLabel.xLabel = \"X-AXIS\"\nlineGraph.plotLabel.yLabel = \"Y-AXIS\"\nlineGraph.plotLineThickness = 3.0\nlineGraph.drawGraphAndOutput(fileName: filePath+\"agg/\"+fileName, renderer: agg_renderer)\n```\n\u003cimg src=\"Tests/SwiftPlotTests/Reference/agg/_01_single_series_line_chart.png\" width=\"500\"\u003e\n\n#### Line Graph with multiple series of data\n\n```swift\nimport SwiftPlot\nimport AGGRenderer\nimport SVGRenderer\n\nlet x1:[Float] = [0,100,263,489]\nlet y1:[Float] = [0,320,310,170]\nlet x2:[Float] = [0,50,113,250]\nlet y2:[Float] = [0,20,100,170]\n\nvar agg_renderer: AGGRenderer = AGGRenderer()\nvar lineGraph = LineGraph\u003cFloat,Float\u003e(enablePrimaryAxisGrid: true)\nlineGraph.addSeries(x1, y1, label: \"Plot 1\", color: .lightBlue)\nlineGraph.addSeries(x2, y2, label: \"Plot 2\", color: .orange)\nlineGraph.plotTitle.title = \"MULTIPLE SERIES\"\nlineGraph.plotLabel.xLabel = \"X-AXIS\"\nlineGraph.plotlabel.yLabel = \"Y-AXIS\"\nlineGraph.plotLineThickness = 3.0\nlineGraph.drawGraphAndOutput(fileName: filePath+\"agg/\"+fileName, renderer: agg_renderer)\n```\n\n\u003cimg src=\"Tests/SwiftPlotTests/Reference/agg/_02_multiple_series_line_chart.png\" width=\"500\"\u003e\n\n#### Line Graph with Sub Plots stacked horizontally\n\n```swift\nimport SwiftPlot\nimport AGGRenderer\n\nlet x:[Float] = [10,100,263,489]\nlet y:[Float] = [10,120,500,800]\n\nvar agg_renderer: AGGRenderer = AGGRenderer()\nvar subplot = SubPlot(layout: .horizontal)\n\nvar lineGraph1 = LineGraph\u003cFloat,Float\u003e(enablePrimaryAxisGrid: true)\nlineGraph1.addSeries(x, y, label: \"Plot 1\", color: .lightBlue)\nlineGraph1.plotTitle.title = \"PLOT 1\"\nlineGraph1.plotLabel.xLabel = \"X-AXIS\"\nlineGraph1.plotLabel.yLabel = \"Y-AXIS\"\nlineGraph1.plotLineThickness = 3.0\n\nvar lineGraph2 = LineGraph\u003cFloat,Float\u003e(enablePrimaryAxisGrid: true)\nlineGraph2.addSeries(x, y, label: \"Plot 2\", color: .orange)\nlineGraph2.plotTitle.title = \"PLOT 2\"\nlineGraph2.plotLabel.xLabel = \"X-AXIS\"\nlineGraph2.plotLabel.yLabel = \"Y-AXIS\"\nlineGraph2.plotLineThickness = 3.0\n\nsubplot.plots = [lineGraph1, lineGraph2]\nsubplot.drawGraphAndOutput(fileName: \"subPlotsHorizontallyStacked\", renderer: agg_renderer)\n```\n\n\u003cimg src=\"Tests/SwiftPlotTests/Reference/agg/_03_sub_plot_horizontally_stacked_line_chart.png\" width=\"500\"\u003e\n\n#### Plot functions using LineGraph\n\n```swift\nimport Foundation\nimport SwiftPlot\nimport AGGRenderer\n\nfunc function(_ x: Float)-\u003eFloat {\n    return 1.0/x\n}\n\nvar agg_renderer: AGGRenderer = AGGRenderer()\nvar lineGraph = LineGraph\u003cFloat,Float\u003e(enablePrimaryAxisGrid: true)\nlineGraph.addFunction(function, minX: -5.0, maxX: 5.0, numberOfSamples: 400, clampY: -50...50, label: \"Function\", color: .orange)\nlineGraph.plotTitle.title = \"FUNCTION\"\nlineGraph.plotLabel.xLabel = \"X-AXIS\"\nlineGraph.plotLabel.yLabel = \"Y-AXIS\"\nlineGraph.drawGraphAndOutput(fileName: \"functionPlotLineGraph\", renderer: agg_renderer)\n```\n\n\u003cimg src=\"Tests/SwiftPlotTests/Reference/agg/_06_function_plot_line_chart.png\" width=\"500\"\u003e\n\n#### Using a secondary axis in LineGraph\n\n```swift\nimport SwiftPlot\nimport AGGRenderer\n\nlet x:[Float] = [10,100,263,489]\nlet y:[Float] = [10,120,500,800]\nlet x1:[Float] = [100,200,361,672]\nlet y1:[Float] = [150,250,628,800]\n\nvar agg_renderer: AGGRenderer = AGGRenderer() \nvar lineGraph = LineGraph\u003cFloat,Float\u003e()\nlineGraph.addSeries(x1, y1, label: \"Plot 1\", color: .lightBlue, axisType: .primaryAxis)\nlineGraph.addSeries(x, y, label: \"Plot 2\", color: .orange, axisType: .secondaryAxis)\nlineGraph.plotTitle.title = \"SECONDARY AXIS\"\nlineGraph.plotLabel.xLabel = \"X-AXIS\"\nlineGraph.plotLabel.yLabel = \"Y-AXIS\"\nlineGraph.plotLineThickness = 3.0\nlineGraph.drawGraphAndOutput(fileName: filePath+\"agg/\"+fileName, renderer: agg_renderer)\n```\nThe series plotted on the secondary axis are drawn dashed.\n\n\u003cimg src=\"Tests/SwiftPlotTests/Reference/agg/_07_secondary_axis_line_chart.png\" width=\"500\"\u003e\n\n#### Displaying plots in Jupyter Notebook\n\nYou can display plots in Jupyter Notebook using only the AGGRenderer.\nTo do so, create the plots as shown in the above examples and instead of using the `drawGraphAndOutput` function from LineGraph, use the `drawGraph` function, then get a base64 encoded image from the AGGRenderer and pass it to the display function as showm below:\n```swift\nlineGraph.drawGraph(renderer: agg_renderer)\ndisplay(base64EncodedPNG: agg_renderer.base64Png())\n```\n\n## How does this work\n\nAll the plotting code, utility functions, and necessary types are included in the SwiftPlot module. Each Renderer is implemented as a separate module. Each Renderer must have SwiftPlot as its dependency and must conform to the Renderer protocol defined in Renderer.swift in the SwiftPlot module. Each plot type is a generic that accepts data conforming to a protocol, FloatConvertible. At the moment FloatConvertible supports both Float and Double.\nThe Renderer protocol defines all the necessary functions that a Renderer needs to implement. \nEach Plot must conform to the Plot protocol. At the moment this protocol defines the necessary variablse and functions that each Plot must implement in order to support SubPlots.\n\u003c/br\u003e\u003c/br\u003e\nYou can add series to the plots using their respective functions(`addSeries` for LineGraph). This is stored in as an array of Series objects. You can set other properties such as plotTitle, plotLabel, plotDimensions, etc. To actually generate the plot you need to call either the `drawGraph` or `drawGraphAndOutput` function. This calculates all the parameters necessary to generate the plots such as the coordinates of the border, scaled points to plot, etc. Then it sends over this information to the renderer which has functions to draw primitives like lines, rectangles and text.\n\u003c/br\u003e\u003c/br\u003e\nIn case the Renderer is in C++(here in the case of AGG), a C wrapper is written which is in turn wrapped in Swift.\n\u003c/br\u003e\u003c/br\u003e\nIn order to display the plots in Jupyter notebook, we encode the image(which is in the form of an RGB buffer) to a PNG image in memory and return the encoded image to the Swift code where it is stored as NSData. Then it is encoded to base64 and passed to the display function in swift-jupyter which finally displays the image.\n\n## Documentation\n\n### LineGraph\u003cT: FloatConvertible, U: FloatConvertible\u003e\n\n|Function                                                                            |Description                                 |\n|------------------------------------------------------------------------------------|--------------------------------------------|\n|init(points: [Point], width: Float = 1000, height: Float = 660, enablePrimaryAxisGrid: Bool = false, enableSecondaryAxisGrid: Bool = false)| Initialize a LineGraph with a set of points |\n|init(width: Float = 1000, height: Float = 660, enablePrimaryAxisGrid: Bool = false,enableSecondaryAxisGrid: Bool = false)| Initialize a LineGraph|\n|addSeries(_ s: Series, axisType: Axis.Location = Axis.Location.primaryAxis)| Add a series to the plot                    |\n|addSeries(points p: [Point], label: String, color: Color = Color.lightBlue, axisType: Axis\u003cT,U\u003e.Location = Axis\u003cT,U\u003e.Location.primaryAxis)         |Add a series to the plot with a set of points, a label and a color for the series |\n|addSeries(_ x: [Float], _ y: [Float], label: String, color: Color = Color.lightBlue, axisType: Axis\u003cT,U\u003e.Location = Axis\u003cT,U\u003e.Location.primaryAxis)|Add a series to the plot with a set of x and y coordinates, a label and a color for the series|\n|addSeries(_ y: [Float], label: String, color: Color = Color.lightBlue, axisType: Axis\u003cT,U\u003e.Location = Axis\u003cT,U\u003e.Location.primaryAxis)|Add a series to the plot with only the y-coordinates. The x-coordinates are automatically enumerated [1, 2, 3, ...]|\n|addFunction(_ function: (Float)-\u003eFloat, minX: Float, maxX: Float, numberOfSamples: Int = 400, label: String, color: Color = Color.lightBlue, axisType: Axis.Location = Axis.Location.primaryAxis)|Add a function to plot along with the range of x-coordinates over which to plot, number of samples of the function to take for plotting, a label, and color for the plot|\n|drawGraphAndOutput(fileName name: String = \"swift_plot_line_graph\", renderer: Renderer)|Generate the plot and save the resultant image|\n|drawGraph(renderer: Renderer)|Generate the plot in memory|\n|drawGraphOutput(fileName name: String = \"swift_plot_line_graph\", renderer: Renderer)|Save the generated plot to disk|\n\n|Property                                         |\n|-------------------------------------------------|\n|plotTitle: PlotTitle? = nil                      |\n|plotLabel: PlotLabel? = nil                      |\n|var plotDimensions: PlotDimensions               |\n|plotLineThickness: Float = 1.5                   |\n|gridLineThickness: Float = 0.5                   |\n|markerTextSize: Float = 12                       |\n|gridColor: Color = .gray                         |\n\n### BarChart\u003cT: LosslessStringConvertible, U: FloatConvertible\u003e\n\n|Function                                                                            |Description                                 |\n|------------------------------------------------------------------------------------|--------------------------------------------|\n|init(width: Float = 1000, height: Float = 660, enableGrid: Bool = false)                                      |Initialize a BarChart                      |\n|addSeries(_ s: Series\u003cT,U\u003e)         |Add a series to the plot .                               |\n|addStackSeries(_ s: Series\u003cT,U\u003e)         |Add a stacked series to the plot                    |\n|addStackSeries(_ x: [U],   label: String, color: Color = .lightBlue, hatchPattern: BarGraphSeriesOptions.Hatching = .none) |Add a stacked series to the plot|\n|addSeries(values: [Pair\u003cT,U\u003e], label: String, color: Color = Color.lightBlue, hatchPattern: BarGraphSeriesOptions.Hatching = .none, graphOrientation: BarGraph.GraphOrientation = .vertical)         |Add a series to the plot using a Pair array|\n|addSeries(_ x: [T], _ y: [U], label: String, color: Color = Color.lightBlue, hatchPattern: BarGraphSeriesOptions.Hatching = .none, graphOrientation: BarGraph.GraphOrientation = .vertical)         |Add a series to the plot using a Pair array|            \n|drawGraphAndOutput(fileName name: String = \"swift_plot_bar_graph\", renderer: Renderer)|Generate the plot and save the resultant image|\n|drawGraph(renderer: Renderer)|Generate the plot in memory|\n|drawGraphOutput(fileName name: String = \"swift_plot_bar_graph\", renderer: Renderer)|Save the generated plot to disk|\n\n|Property                                         |\n|-------------------------------------------------|\n|plotTitle: PlotTitle? = nil                      |\n|plotLabel: PlotLabel? = nil                      |\n|var plotDimensions: PlotDimensions               |\n|space: Int = 20 (Sets the space between two bars)|\n|gridLineThickness: Float = 0.5                   |\n|markerTextSize: Float = 12                       |\n|gridColor: Color = .gray                         |\n\n### Histogram\u003cT:FloatConvertible\u003e\n\n|Function                                                                            |Description                                 |\n|------------------------------------------------------------------------------------|--------------------------------------------|\n|init(width: Float = 1000, height: Float = 660, isNormalized: Bool = false, enableGrid: Bool = false)                                      |Initialize a Histogram                      |\n|addSeries(_ s: HistogramSeries\u003cT\u003e)|Add a series to the plot.|\n|addSeries(data: [T], bins: Int, label: String, color: Color = .lightBlue, histogramType: HistogramSeriesOptions.HistogramType = .bar) | Add a series using an array. |\n|addStackSeries(data: [T], label: String, color: Color = .lightBlue) |Add a stacked series to the plot|           \n|drawGraphAndOutput(fileName name: String = \"swift_plot_histogram\", renderer: Renderer)|Generate the plot and save the resultant image|\n|drawGraph(renderer: Renderer)|Generate the plot in memory|\n|drawGraphOutput(fileName name: String = \"swift_plot_histogram\", renderer: Renderer)|Save the generated plot to disk|\n \n|Property                           |\n|-----------------------------------|\n|plotTitle: PlotTitle? = nil        |\n|plotLabel: PlotLabel? = nil        |\n|var plotDimensions: PlotDimensions |\n|var strokeWidth: Float = 2         |\n|gridLineThickness: Float = 0.5     |\n|markerTextSize: Float = 12         |\n|gridColor: Color = .gray           |\n\n### ScatterPlot\u003cT:FloatConvertible, U:FloatConvertible\u003e\n\n|Function                                                                            |Description                                 |\n|------------------------------------------------------------------------------------|--------------------------------------------|\n|init(width: Float = 1000, height: Float = 660, isNormalized: Bool = false, enableGrid: Bool = false)                                      |Initialize a ScatterPlot.                     |\n|init(points p: [Pair\u003cT,U\u003e], width: Float = 1000, height: Float = 660, enableGrid: Bool = false)                                            |Initialize a ScatterPlot.                     |\n|addSeries(_ s: Series\u003cT,U\u003e)|Add a series to the plot.|\n|addSeries(points: [Pair\u003cT,U\u003e], label: String, color: Color = .lightBlue, scatterPattern: ScatterPlotSeriesOptions.ScatterPattern = .circle) | Add a series using an array of Pairs. |\n|addSeries(_ x: [T], _ y: [U], label: String, color: Color = .lightBlue, scatterPattern: ScatterPlotSeriesOptions.ScatterPattern = .circle) | Add a series using separate x and y arrays. |\n|addSeries(_ x: [T], _ y: [U], label: String, startColor: Color = .lightBlue, endColor: Color = .lightBlue, scatterPattern: ScatterPlotSeriesOptions.ScatterPattern = .circle)) | Add a series using separate x and y arrays and specify a start and end color for the scatter points. |\n|addSeries(_ y: [U], label: String, color: Color = .lightBlue, scatterPattern: ScatterPlotSeriesOptions.ScatterPattern = .circle) | Add a series using just the y array. It will be plotted against the index of the point. |\n|addSeries(_ y: [U], label: String, startColor: Color = .lightBlue, endColor: Color = .lightBlue, scatterPattern: ScatterPlotSeriesOptions.ScatterPattern = .circle) | Add a series using just the y array. It will be plotted against the index of the point. Also specify the start and end color for the scatter points.|        \n|drawGraphAndOutput(fileName name: String = \"swift_plot_scatter_plot\", renderer: Renderer)|Generate the plot and save the resultant image|\n|drawGraph(renderer: Renderer)|Generate the plot in memory|\n|drawGraphOutput(fileName name: String = \"swift_plot_scatter_plot\", renderer: Renderer)|Save the generated plot to disk|\n \n|Property                           |\n|-----------------------------------|\n|plotTitle: PlotTitle? = nil        |\n|plotLabel: PlotLabel? = nil        |\n|plotDimensions: PlotDimensions     |\n|scatterPatternSize: Float = 10     |\n|gridLineThickness: Float = 0.5     |\n|markerTextSize: Float = 12         |\n|gridColor: Color = .gray           |\n\n### SubPlot\n\n|enum stackPattern (to be passed in place of stackPattern in the initializer)|\n|----------------------------------------------------------------------------|\n|verticallyStacked                                                           |\n|horizontallyStacked                                                         |\n|gridStacked                                                                 |\n\n|Function                                                                            |Description                                 |\n|------------------------------------------------------------------------------------|--------------------------------------------|\n|init(width: Float = 1000, height: Float = 660, numberOfPlots n: Int = 1, numberOfRows nR: Int = 1, numberOfColumns nC: Int = 1, stackPattern: Int = 0)|Initialize a SubPlot |\n|draw(plots: [Plot], renderer: Renderer, fileName: String = \"subPlot_output\")|Generate plot with the plots passed in as Sub Plots and save the image to disk|\n\n### PlotDimensions\n\n|Function                                                  |Description                                                    |\n|----------------------------------------------------------|---------------------------------------------------------------|\n|init(frameWidth : Float = 1000, frameHeight : Float = 660)|Create a PlotDimensions variable with a frame width and height |\n\n### Pair\u003cT,U\u003e\n\n|Property |\n|---------|\n|x: T     |\n|y: U     |\n\n|Function                    |Description                              |\n|----------------------------|-----------------------------------------|\n|init(_ x: T, _ y: T)        |Create a Pair using x and y              |\n\n\n|typealias                   |\n|----------------------------|\n|Point = Pair\u003cFloat, Float\u003e  |\n\n|Property                          |\n|----------------------------------|\n|zeroPoint = Point(0.0, 0.0)       |\n\n### PlotLabel\n\n|Property                          |\n|----------------------------------|\n|xLabel: String = \"X-Axis\"         |\n|yLabel: String = \"Y-Axis\"         |\n|labelSize: Float = 15             |\n|xLabelLocation = zeroPoint        |\n|yLabelLocation = zeroPoint        |\n\n### PlotTitle\n\n|Property                 |\n|-------------------------|\n|title : String = \"TITLE\" |\n|titleSize : Float = 15   |\n|titleLocation = zeroPoint|\n\n### Color\n\n|Function                                            |Description                                                                |\n|----------------------------------------------------|--------------------------------------------------------------------------|\n|init(_ r: Float, _ g: Float, _ b: Float, _ a: Float)|Create a Color with r, g, b and a values. Each of them being between 0.0 and 1.0|\n\n|Property(only on macOS and iOS)                    |\n|---------------------------------------------------|\n|cgColor: CGColor (return the corresponding CGColor)|\n\nBuilt-in Colors can be found [here](https://github.com/KarthikRIyer/swiftplot/blob/master/Sources/SwiftPlot/Color.swift).\n\n\n### PlotLabel\n\n|Property                          |\n|----------------------------------|\n|xLabel: String = \"X-Axis\"         |\n|yLabel: String = \"Y-Axis\"         |\n|labelSize: Float = 15             |\n|xLabelLocation = zeroPoint        |\n|yLabelLocation = zeroPoint        |\n\n### Axis\u003cT,U\u003e\n\n|enum Location (to be passed into addSeries function in LineGraph)|\n|-----------------------------------------------------------------|\n|primaryAxis                                                      |\n|secondaryAxis                                                    |\n\n### ScatterPlotSeriesOptions\n\n|enum ScatterPattern (to be passed into addSeries function in ScatterPlot)|\n|-------------------------------------------------------------------------|\n|circle                                                                   |\n|square                                                                   |\n|triangle                                                                 |\n|diamond                                                                  |\n|hexagon                                                                  |\n|pentagon                                                                 |\n|star                                                                     |\n\n\n### HistogramSeriesOptions\n\n|enum HistogramType: CaseIterable (to be passed into addSeries function in Histogram)|\n|------------------------------------------------------------------------------------|\n|bar                                                                                 |\n|step                                                                                |\n\n### BarGraphSeriesOptions\n\n|enum Hatching: Int, CaseIterable (to be passed into addSeries function in BarGraph)|\n|------------------------------------------------------------------------------------|\n|none = 0                                                                            |\n|forwardSlash = 1                                                                    |\n|backwardSlash = 2                                                                   |\n|hollowCircle = 3                                                                    |\n|filledCircle = 4                                                                    |\n|vertical = 5                                                                        |\n|horizontal = 6                                                                      |\n|grid = 7                                                                            |\n|cross = 8                                                                           |\n\n### Base64Encoder\n\n|Function                                            |Description                                                                |\n|----------------------------------------------------|--------------------------------------------------------------------------|\n|encodeBase64PNG(pngBufferPointer: UnsafePointer\u003cUInt8\u003e, bufferSize: Int) -\u003e String|Encode a PNG image into base64 format.|\n\n## Limitations\n- FloatConvertible supports only Float and Double. We plan to extend this to Int in the future.\n\n## Guidelines for Contributors\nIf you want to contribute to improve this library, please read our [guidelines](https://github.com/KarthikRIyer/swiftplot/blob/master/CONTRIBUTING.md). Feel free to [open an issue](https://github.com/KarthikRIyer/swiftplot/issues).\n\n## Credits\n1. Maxim Shemanarev : The AGG library is directly used to render plots.\n2. [Lode Vandevenne](https://github.com/lvandeve) : The lodepng library is directly used to encode PNG images.\n3. [The FreeType Project](https://www.freetype.org) : AGG uses FreeType to draw text.\n4. [Brad Larson](https://github.com/BradLarson) and [Marc Rasi](https://github.com/marcrasi) for their invaluable guidance.","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKarthikRIyer%2Fswiftplot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKarthikRIyer%2Fswiftplot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKarthikRIyer%2Fswiftplot/lists"}