IPlot 0.0.1-pre9
See the version list below for details.
dotnet add package IPlot --version 0.0.1-pre9
NuGet\Install-Package IPlot -Version 0.0.1-pre9
<PackageReference Include="IPlot" Version="0.0.1-pre9" />
paket add IPlot --version 0.0.1-pre9
#r "nuget: IPlot, 0.0.1-pre9"
// Install IPlot as a Cake Addin #addin nuget:?package=IPlot&version=0.0.1-pre9&prerelease // Install IPlot as a Cake Tool #tool nuget:?package=IPlot&version=0.0.1-pre9&prerelease
IPlot
Charting library for .NET, rendered using Plotly or HighCharts in the browser.
Table of contents
About
This library aims to provide a fast and fluid way of curating a chart in both C# and F#, where you begin by throwing some data at a chart and later refine its properties to adjust its appearance or behaviour. Intellisense can help discovery of appropriate properties to set, and provide info on the expected arguments via static typing. This can reduce the amount of documentation lookup required to set up a plot and adjust its visual elements.
The API is intentionally similar to XPlot.Plotly, where most access is achieved through interacting with the
Chart
element.
You can choose to render charts using Plotly or HighCharts. Either import IPlot.Plotly
or IPlot.HighCharts
- the chart API is very similar.
Install
Install as a nuget package using the dotnet CLI. Whilst in the directory containing your csproj or fsproj file, enter:
dotnet add package IPlot --version=0.0.1-pre10
Basic Usage
Using the Ploty API, a basic line chart can be generated as follows:
using IPlot.Plotly
var data = new double[] { 0.0, 0.7, 0.4, 1.0 };
Chart.Line(data)
.WithWidth(1200)
.WithHeight(800)
.WithTitle("Line plot")
.With(Chart.Props.layout.plot_bgcolor("#999"))
.Show();
...and in F#:
open IPlot.Plotly
[ 0.0; 0.7; 0.4; 1.0]
|> Chart.Line
|> Chart.WithWidth 1200
|> Chart.WithHeight 800
|> Chart.WithTitle "Line Plot"
|> Chart.With(Chart.Props.layout.plot_bgcolor "#999")
|> Chart.Show
In HighCharts, this would be:
open IPlot.HighCharts
[ 0.0; 0.7; 0.4; 1.0]
|> Chart.Line
|> Chart.WithWidth 1200
|> Chart.WithHeight 800
|> Chart.WithTitle "Line Plot"
|> Chart.With(Chart.Props.chart_iplot.plotBackgroundColor "#999")
|> Chart.Show
Unified API
Regardless of the renderer (Plotly or HighCharts), the workflow is intended to feel the same. Both use the Chart functions to set up and manipulate charts, and both allow use of the Chart.With function to adjust chart element properties.
Chart Functions
Most functionality can be achieved by using the functions (static methods) contained in the Chart class. There are two main ways of generating a chart:
- Traces (or series) can be created first, and then provided to the
Chart.Plot
function, before being shown. - You can directly use one of the utility methods of Chart (e.g.
Chart.Cylinder()
orChart.Heatmap()
) to create the traces, simply passing the data. For example,Chart.Area()
will create a trace of typeArea
and avoid the need to instantiate any specific traces or properties.
Property setting
Once a chart has been created (using either Chart.Plot
or another utility method of the Chart
class) then its properties can be manipulated.
Calls to Chart.With()
calls can be chained as follows:
open IPlot.Plotly
[trace1; trace2]
|> Chart.Plot
|> Chart.With (Chart.Props.traces.[0].asScatter.mode "markers")
|> Chart.With (Chart.Props.traces.[0].asScatter.marker.size 12.)
|> Chart.With (Chart.Props.traces.[1].asScatter.line.width 5.0)
|> Chart.With (Chart.Props.traces.[1].asScatter.line.color "#44FF22")
|> Chart.With (Chart.Props.layout.showlegend false)
|> Chart.With (Chart.Props.layout.plot_bgcolor "#334433")
|> Chart.WithWidth 1200
|> Chart.Show
In HighCharts the access pattern is the same:
open IPlot.HighCharts
Chart.Cylinder [1.; 2.; 3.; 4.; 3.; 2.; 1.]
|> Chart.With (Chart.Props.chart_iplot.options3d.enabled true)
|> Chart.With (Chart.Props.chart_iplot.options3d.viewDistance 25.)
|> Chart.WithWidth 700
|> Chart.WithHeight 500
|> Chart.Show
Saving Images
The highCharts API has a function that allows storing the chart as a PNG file locally:
open IPlot.HighCharts
Chart.Line [1.; 3.; 2.; 6.]
|> Chart.WithWidth 700
|> Chart.WithHeight 500
|> Cchart.WithTitle "Image file of line chart"
|> Chart.Save "MyChart.png"
Building From Source
The library can be built from source on the command line (in order):
.\gensrc.cmd
.\buildsrc.cmd
All tests can also be run using the following command:
.\runtests.cmd
The nuget package can be created by running:
.\pack.cmd
.NET Interactive
IPlot can be used within .NET interactive notebooks by importing IPlot.Interactive. To get the chart to render in the cell output simply skip the Chart.Show() call at the end:
#r "nuget: IPlot, 0.0.1-10"
#r "nuget: IPlot.Interactive, 0.0.1-pre10"
open IPlot.Plotly
let xs = [ -20f..20f ]
let ys = [ for x in xs do x ** 2f ]
(xs, ys)
||> List.zip
|> Chart.Scatter
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- FSharp.Core (>= 5.0.0)
- IPlot.HighCharts (>= 1.2.0-pre9)
- IPlot.Plotly (>= 1.1.0-pre8)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on IPlot:
Package | Downloads |
---|---|
IPlot.Interactive
Charting library for generating charts with HighCharts or Plotly |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.1 | 855 | 4/11/2021 |
0.0.1-pre9 | 702 | 3/26/2021 |
0.0.1-pre8 | 711 | 12/14/2020 |
0.0.1-pre7 | 932 | 12/5/2020 |
0.0.1-pre6 | 854 | 12/5/2020 |
0.0.1-pre5 | 861 | 12/3/2020 |
0.0.1-pre4 | 709 | 12/3/2020 |
0.0.1-pre3 | 782 | 12/2/2020 |
0.0.1-pre2 | 748 | 11/30/2020 |
0.0.1-pre10 | 651 | 3/28/2021 |
0.0.1-pre1 | 680 | 11/30/2020 |