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
FigureBackground
Style for the background of the entire figure
public BackgroundStyle FigureBackground
Field Value
Properties
Add
public PlottableAdder Add { get; }
Property Value
Axes
public AxisManager Axes { get; }
Property Value
Benchmark
public IPlottable Benchmark { get; set; }
Property Value
Font
public FontStyler Font { get; }
Property Value
Grid
public DefaultGrid Grid { get; }
Property Value
LastRender
public RenderDetails LastRender { get; }
Property Value
Layout
public LayoutManager Layout { get; }
Property Value
Legend
public Legend Legend { get; set; }
Property Value
PlotControl
In GUI environments this property holds a reference to the interactive plot control
public IPlotControl? PlotControl { get; set; }
Property Value
PlottableList
public List<IPlottable> PlottableList { get; }
Property Value
RenderManager
public RenderManager RenderManager { get; }
Property Value
ScaleFactor
public double ScaleFactor { get; set; }
Property Value
Style
[Obsolete("This class is deprecated. Use SetStyle() and GetStyle(). See the ScottPlot Cookbook for details.", true)]
public PlotStyler Style { get; }
Property Value
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
ZoomRectangle
public IZoomRectangle ZoomRectangle { get; set; }
Property Value
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
PixelPoint
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 pixelspublic CoordinateRect GetCoordinateRect(Coordinates coordinates, float radius = 10, IXAxis? xAxis = null, IYAxis? yAxis = null)
Parameters
coordinates
Coordinatesradius
floatxAxis
IXAxisyAxis
IYAxis
Returns
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 pixelspublic CoordinateRect GetCoordinateRect(Pixel pixel, float radius = 10, IXAxis? xAxis = null, IYAxis? yAxis = null)
Parameters
Returns
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 pixelspublic CoordinateRect GetCoordinateRect(float x, float y, float radius = 10, IXAxis? xAxis = null, IYAxis? yAxis = null)
Parameters
Returns
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
Returns
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
Returns
GetDefaultGrid()
[Obsolete("This method is deprecated. Access Plot.Grid instead.", true)]
public static DefaultGrid GetDefaultGrid()
Returns
GetImage(int, int)
public Image GetImage(int width, int height)
Parameters
Returns
GetImageBytes(int, int, ImageFormat)
public byte[] GetImageBytes(int width, int height, ImageFormat format = ImageFormat.Bmp)
Parameters
width
intheight
intformat
ImageFormat
Returns
- byte[]
GetImageHtml(int, int)
[Obsolete("This method is deprecated. Use GetPngHtml() or GetSvgHtml()", true)]
public string GetImageHtml(int width, int height)
Parameters
Returns
GetLegendImage()
Returns the content of the legend as a raster image
public Image GetLegendImage()
Returns
GetLegendSvgXml()
Returns the content of the legend as SVG (vector) image
public string GetLegendSvgXml()
Returns
GetPanel(Pixel, bool)
Get the panel under a given pixel
public IPanel? GetPanel(Pixel pixel, bool axesOnly)
Parameters
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
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
CoordinatesxAxis
IXAxisyAxis
IYAxis
Returns
GetPlottables()
Return contents of PlottableList.
public IEnumerable<IPlottable> GetPlottables()
Returns
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
Returns
GetStyle()
Return the current style settings for this plot
public PlotStyle GetStyle()
Returns
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
Returns
GetSvgXml(int, int)
public string GetSvgXml(int width, int height)
Parameters
Returns
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
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
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
Render(SKCanvas, int, int)
Render onto an existing canvas with the given dimensions
public void Render(SKCanvas canvas, int width, int height)
Parameters
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
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
Save(string, int, int)
public SavedImageInfo Save(string filePath, int width, int height)
Parameters
Returns
Save(string, int, int, ImageFormat, int)
public SavedImageInfo Save(string filePath, int width, int height, ImageFormat format, int quality = 85)
Parameters
filePath
stringwidth
intheight
intformat
ImageFormatquality
int
Returns
SaveBmp(string, int, int)
public SavedImageInfo SaveBmp(string filePath, int width, int height)
Parameters
Returns
SaveJpeg(string, int, int, int)
public SavedImageInfo SaveJpeg(string filePath, int width, int height, int quality = 85)
Parameters
Returns
SavePng(string, int, int)
public SavedImageInfo SavePng(string filePath, int width, int height)
Parameters
Returns
SaveSvg(string, int, int)
public SavedImageInfo SaveSvg(string filePath, int width, int height)
Parameters
Returns
SaveWebp(string, int, int, int)
public SavedImageInfo SaveWebp(string filePath, int width, int height, int quality = 85)
Parameters
Returns
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
ShowLegend(Alignment)
public Legend ShowLegend(Alignment alignment)
Parameters
alignment
Alignment
Returns
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
Alignmentorientation
Orientation
Returns
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
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
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
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
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)