Table of Contents

Class Plot

Namespace
ScottPlot
Assembly
ScottPlot.dll
public class Plot : IDisposable
Inheritance
Plot
Implements
Inherited Members
Extension Methods

Constructors

Plot()

public Plot()

Fields

DataBackground

Style for the data area (the area within the axis frames)

public BackgroundStyle DataBackground

Field Value

BackgroundStyle

FigureBackground

Style for the background of the entire figure

public BackgroundStyle FigureBackground

Field Value

BackgroundStyle

Properties

Add

public PlottableAdder Add { get; }

Property Value

PlottableAdder

Axes

public AxisManager Axes { get; }

Property Value

AxisManager

Benchmark

public IPlottable Benchmark { get; set; }

Property Value

IPlottable

Font

public FontStyler Font { get; }

Property Value

FontStyler

Grid

public DefaultGrid Grid { get; }

Property Value

DefaultGrid

LastRender

public RenderDetails LastRender { get; }

Property Value

RenderDetails

Layout

public LayoutManager Layout { get; }

Property Value

LayoutManager

Legend

public Legend Legend { get; set; }

Property Value

Legend

PlotControl

In GUI environments this property holds a reference to the interactive plot control

public IPlotControl? PlotControl { get; set; }

Property Value

IPlotControl

PlottableList

public List<IPlottable> PlottableList { get; }

Property Value

List<IPlottable>

RenderManager

public RenderManager RenderManager { get; }

Property Value

RenderManager

ScaleFactor

public double ScaleFactor { get; set; }

Property Value

double

Style

[Obsolete("This class is deprecated. Use SetStyle() and GetStyle(). See the ScottPlot Cookbook for details.", true)]
public PlotStyler Style { get; }

Property Value

PlotStyler

Sync

This object is locked by the Render() methods. Logic that manipulates the plot (UI inputs or editing data) can lock this object to prevent rendering artifacts.

public object Sync { get; }

Property Value

object

ZoomRectangle

public IZoomRectangle ZoomRectangle { get; set; }

Property Value

IZoomRectangle

Methods

Clear()

Clears the PlottableList list

public void Clear()

Clear<T>()

Clear a all instances of a specific type from the PlottableList.

public void Clear<T>() where T : IPlottable

Type Parameters

T

Type of IPlottable to be cleared

Developer_ShowAxisDetails(bool)

public void Developer_ShowAxisDetails(bool enable = true)

Parameters

enable bool

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetAxis(Pixel)

Get the axis under a given pixel

public IAxis? GetAxis(Pixel pixel)

Parameters

pixel Pixel

Point

Returns

IAxis

The axis at pixel (or null)

GetCoordinateRect(Coordinates, float, IXAxis?, IYAxis?)

Return a coordinate rectangle centered at a coordinate pair with the radius specified in pixels. Uses measurements from the most recent render.

Center point in coordinate units Radius in pixels The coordinate rectangle
public CoordinateRect GetCoordinateRect(Coordinates coordinates, float radius = 10, IXAxis? xAxis = null, IYAxis? yAxis = null)

Parameters

coordinates Coordinates
radius float
xAxis IXAxis
yAxis IYAxis

Returns

CoordinateRect

GetCoordinateRect(Pixel, float, IXAxis?, IYAxis?)

Return a coordinate rectangle centered at a pixel. Uses measurements from the most recent render.

Center point pixel Radius in pixels The coordinate rectangle
public CoordinateRect GetCoordinateRect(Pixel pixel, float radius = 10, IXAxis? xAxis = null, IYAxis? yAxis = null)

Parameters

pixel Pixel
radius float
xAxis IXAxis
yAxis IYAxis

Returns

CoordinateRect

GetCoordinateRect(float, float, float, IXAxis?, IYAxis?)

Return a coordinate rectangle centered at a pixel. Uses measurements from the most recent render.

Center point pixel's x Center point pixel's y Radius in pixels The coordinate rectangle
public CoordinateRect GetCoordinateRect(float x, float y, float radius = 10, IXAxis? xAxis = null, IYAxis? yAxis = null)

Parameters

x float
y float
radius float
xAxis IXAxis
yAxis IYAxis

Returns

CoordinateRect

GetCoordinates(Pixel, IXAxis?, IYAxis?)

Return the coordinate for a specific pixel using measurements from the most recent render.

public Coordinates GetCoordinates(Pixel pixel, IXAxis? xAxis = null, IYAxis? yAxis = null)

Parameters

pixel Pixel
xAxis IXAxis
yAxis IYAxis

Returns

Coordinates

GetCoordinates(float, float, IXAxis?, IYAxis?)

Return the coordinate for a specific pixel using measurements from the most recent render.

public Coordinates GetCoordinates(float x, float y, IXAxis? xAxis = null, IYAxis? yAxis = null)

Parameters

x float
y float
xAxis IXAxis
yAxis IYAxis

Returns

Coordinates

GetDefaultGrid()

[Obsolete("This method is deprecated. Access Plot.Grid instead.", true)]
public static DefaultGrid GetDefaultGrid()

Returns

DefaultGrid

GetImage(int, int)

public Image GetImage(int width, int height)

Parameters

width int
height int

Returns

Image

GetImageBytes(int, int, ImageFormat)

public byte[] GetImageBytes(int width, int height, ImageFormat format = ImageFormat.Bmp)

Parameters

width int
height int
format ImageFormat

Returns

byte[]

GetImageHtml(int, int)

[Obsolete("This method is deprecated. Use GetPngHtml() or GetSvgHtml()", true)]
public string GetImageHtml(int width, int height)

Parameters

width int
height int

Returns

string

GetLegendImage()

Returns the content of the legend as a raster image

public Image GetLegendImage()

Returns

Image

GetLegendSvgXml()

Returns the content of the legend as SVG (vector) image

public string GetLegendSvgXml()

Returns

string

GetPanel(Pixel, bool)

Get the panel under a given pixel

public IPanel? GetPanel(Pixel pixel, bool axesOnly)

Parameters

pixel Pixel

Point

axesOnly bool

Returns

IPanel

The panel at pixel (or null)

GetPixel(Coordinates)

Return the location on the screen (pixel) for a location on the plot (coordinates) on the default axes. The figure size and layout referenced will be the one from the last render.

public Pixel GetPixel(Coordinates coordinates)

Parameters

coordinates Coordinates

Returns

Pixel

GetPixel(Coordinates, IXAxis, IYAxis)

Return the location on the screen (pixel) for a location on the plot (coordinates) on the given axes. The figure size and layout referenced will be the one from the last render.

public Pixel GetPixel(Coordinates coordinates, IXAxis xAxis, IYAxis yAxis)

Parameters

coordinates Coordinates
xAxis IXAxis
yAxis IYAxis

Returns

Pixel

GetPlottables()

Return contents of PlottableList.

public IEnumerable<IPlottable> GetPlottables()

Returns

IEnumerable<IPlottable>

GetPlottables<T>()

Return all plottables in PlottableList of the given type.

public IEnumerable<T> GetPlottables<T>() where T : IPlottable

Returns

IEnumerable<T>

Type Parameters

T

GetPngHtml(int, int, string, string)

Render the plot and return an HTML img element containing a Base64-encoded PNG

public string GetPngHtml(int width, int height, string classContent = "", string styleContent = "")

Parameters

width int
height int
classContent string
styleContent string

Returns

string

GetStyle()

Return the current style settings for this plot

public PlotStyle GetStyle()

Returns

PlotStyle

GetSvgHtml(int, int)

Render the plot and return a plain text SVG element suitable for insertion into HTML

public string GetSvgHtml(int width, int height)

Parameters

width int
height int

Returns

string

GetSvgXml(int, int)

public string GetSvgXml(int width, int height)

Parameters

width int
height int

Returns

string

HideAxesAndGrid()

Disable visibility for all axes and grids

public void HideAxesAndGrid()

HideGrid()

Disable visibility for all grids

public void HideGrid()

HideLegend()

Helper method for setting visibility of the Legend

public Legend HideLegend()

Returns

Legend

MoveToBack(IPlottable)

Move the indicated plottable to the start of the list so it is rendered first

public void MoveToBack(IPlottable plottable)

Parameters

plottable IPlottable

MoveToBottom(IPlottable)

Move the indicated plottable to the start of the list so it is rendered first and appears below all other plottables.

public void MoveToBottom(IPlottable plottable)

Parameters

plottable IPlottable

MoveToFront(IPlottable)

Move the indicated plottable to the end of the list so it is rendered last

public void MoveToFront(IPlottable plottable)

Parameters

plottable IPlottable

MoveToTop(IPlottable)

Move the indicated plottable to the end of the list so it is rendered last and appears above all other plottables.

public void MoveToTop(IPlottable plottable)

Parameters

plottable IPlottable

Remove(IAxis)

Remove the given Axis from the Axes.

public void Remove(IAxis axis)

Parameters

axis IAxis

Remove(IPanel)

Remove the given Panel from the Axes.

public void Remove(IPanel panel)

Parameters

panel IPanel

Remove(IPlottable)

Remove the given plottable from the PlottableList.

public void Remove(IPlottable plottable)

Parameters

plottable IPlottable

Remove(Type)

Remove all items of a specific type from the PlottableList.

public void Remove(Type plotType)

Parameters

plotType Type

Remove<T>()

Remove a all instances of a specific type from the PlottableList.

public void Remove<T>() where T : IPlottable

Type Parameters

T

Type of IPlottable to be removed

Remove<T>(Func<T, bool>)

Remove all instances of a specific type from the PlottableList that meet the predicate criteraia.

public void Remove<T>(Func<T, bool> predicate) where T : IPlottable

Parameters

predicate Func<T, bool>

A function to test each element for a condition.

Type Parameters

T

Type of IPlottable to be removed

Render(SKCanvas, PixelRect)

Render onto an existing canvas inside the given rectangle

public void Render(SKCanvas canvas, PixelRect rect)

Parameters

canvas SKCanvas
rect PixelRect

Render(SKCanvas, int, int)

Render onto an existing canvas with the given dimensions

public void Render(SKCanvas canvas, int width, int height)

Parameters

canvas SKCanvas
width int
height int

Render(SKSurface)

Render onto an existing canvas of a surface over the local clip bounds

public void Render(SKSurface surface)

Parameters

surface SKSurface

Render(int, int)

[Obsolete("Call GetImage() to create a new image, RenderInMemory() to force a render for layout purposes, or Render() to render onto an existing SkiaSharp surface or canvas.", true)]
public void Render(int width = 400, int height = 300)

Parameters

width int
height int

RenderInMemory(int, int)

Create a new image of the given dimensions, render the plot onto it, and return it.

public void RenderInMemory(int width = 400, int height = 300)

Parameters

width int
height int

Save(string, int, int)

public SavedImageInfo Save(string filePath, int width, int height)

Parameters

filePath string
width int
height int

Returns

SavedImageInfo

Save(string, int, int, ImageFormat, int)

public SavedImageInfo Save(string filePath, int width, int height, ImageFormat format, int quality = 85)

Parameters

filePath string
width int
height int
format ImageFormat
quality int

Returns

SavedImageInfo

SaveBmp(string, int, int)

public SavedImageInfo SaveBmp(string filePath, int width, int height)

Parameters

filePath string
width int
height int

Returns

SavedImageInfo

SaveJpeg(string, int, int, int)

public SavedImageInfo SaveJpeg(string filePath, int width, int height, int quality = 85)

Parameters

filePath string
width int
height int
quality int

Returns

SavedImageInfo

SavePng(string, int, int)

public SavedImageInfo SavePng(string filePath, int width, int height)

Parameters

filePath string
width int
height int

Returns

SavedImageInfo

SaveSvg(string, int, int)

public SavedImageInfo SaveSvg(string filePath, int width, int height)

Parameters

filePath string
width int
height int

Returns

SavedImageInfo

SaveWebp(string, int, int, int)

public SavedImageInfo SaveWebp(string filePath, int width, int height, int quality = 85)

Parameters

filePath string
width int
height int
quality int

Returns

SavedImageInfo

SetStyle(Plot)

Apply the style settings from the given plot to this plot

public void SetStyle(Plot otherPlot)

Parameters

otherPlot Plot

SetStyle(PlotStyle)

Apply the given style settings to this plot

public void SetStyle(PlotStyle style)

Parameters

style PlotStyle

ShowAxesAndGrid()

Enable visibility for all axes and grids

public void ShowAxesAndGrid()

ShowGrid()

Enable visibility for all grids

public void ShowGrid()

ShowLegend()

Helper method for setting visibility of the Legend

public Legend ShowLegend()

Returns

Legend

ShowLegend(Alignment)

Helper method for setting visibility of the Legend and setting Location to the provided one.

public Legend ShowLegend(Alignment alignment)

Parameters

alignment Alignment

Returns

Legend

ShowLegend(Alignment, Orientation)

Helper method for setting the Legend's IsVisible, Alignment, and Orientation properties all at once.

public Legend ShowLegend(Alignment alignment, Orientation orientation)

Parameters

alignment Alignment
orientation Orientation

Returns

Legend

ShowLegend(Edge)

Hide the default legend (inside the data area) and create a new legend panel placed on the edge of the figure outside the data area.

public LegendPanel ShowLegend(Edge edge)

Parameters

edge Edge

Returns

LegendPanel

ShowLegend(IEnumerable<LegendItem>, Alignment)

Helper method for displaying specific items in the legend

public Legend ShowLegend(IEnumerable<LegendItem> items, Alignment location = Alignment.LowerRight)

Parameters

items IEnumerable<LegendItem>
location Alignment

Returns

Legend

Title(bool)

Shortcut to show or hide the title by setting Axes.Title.IsVisible. Reference properties of Axes.Title to customize size, color, font, etc.

public void Title(bool show)

Parameters

show bool

Title(string?, float?)

Shortcut to set text of the Axes.Title Label and enable its visibility. Reference properties of Axes.Title to customize size, color, font, etc.

public void Title(string? text = null, float? size = null)

Parameters

text string
size float?

XLabel(string, float?)

Shortcut to set text of the BottomAxis Label Assign properties of BottomAxis Label to customize size, color, font, etc.

public void XLabel(string label, float? size = null)

Parameters

label string
size float?

YLabel(string, float?)

Shortcut to set text of the BottomAxis Label Assign properties of BottomAxis Label to customize size, color, font, etc.

public void YLabel(string label, float? size = null)

Parameters

label string
size float?