Plot Class

A chart, described with the grammar of graphics: layers of marks (bars, lines, dots, arcs...) whose channels are mapped by scales (x, y, color, size) and placed by coordinates (Cartesian or polar).

public sealed class Plot

Remarks

Every chart type is a combination of these pieces. The scales, the axes and the legend are inferred from the marks unless they are set. Plot.CreateScene lays the chart out into a ChartScene; Plot.ToSvg writes it as SVG. The output is deterministic: the same plot always gives the same SVG.

Constructors

NameDescription
Plot()

Plot()

Plot.cs
public Plot()

No documentation is available.

Properties

NameDescription
ClipGets or sets a value that indicates whether the marks are clipped to the plot area. Use it with a domain narrower than the data.
ColorScaleGets or sets the color scale, or null to infer it from the marks.
CoordinatesGets or sets the coordinates, or null for the default: polar for arcs (pies, donuts, gauges), Cartesian otherwise.
DescriptionGets or sets the accessible description of the chart (an SVG desc). It is not drawn.
FacetsGets the options of the grid of small charts, when marks have facets (Mark<T>.FacetX, Mark<T>.FacetY).
HeightGets or sets the height of the chart, in pixels. The default is 400.
LegendGets the options of the legend of the color scale.
MarginGets or sets the space around the plot area, or null to compute it from the axes, the title and the legend.
MarksGets the marks, drawn in order: the first one is at the bottom.
SecondaryYAxisGets the options of the axis of the secondary y scale. It has no grid lines by default.
SecondaryYScaleGets or sets the secondary y scale, used by the marks that set Mark.UseSecondaryYScale, or null to infer it from them. In Cartesian coordinates, its axis is on the right of the chart; in transposed and polar coordinates, it has no axis.
SizeLegendGets the options of the legend of the size scale, drawn next to the legend of the color scale.
SizeScaleGets or sets the size scale, or null for the default.
SubtitleGets or sets the subtitle, drawn under the title.
TextMeasurerGets or sets the measurer of the texts, or null for AfmTextMeasurer.Default.
ThemeGets or sets the theme. The default is ChartTheme.Light.
TitleGets or sets the title, drawn at the top of the chart and used as its accessible name.
WidthGets or sets the width of the chart, in pixels. The default is 640.
XAxisGets the options of the axis of the x scale.
XScaleGets or sets the x scale, or null to infer it from the marks.
YAxisGets the options of the axis of the y scale.
YScaleGets or sets the y scale, or null to infer it from the marks.

Gets or sets a value that indicates whether the marks are clipped to the plot area. Use it with a domain narrower than the data.

public bool Clip { get; set; }

Property value

bool

ColorScale

Plot.cs

Gets or sets the color scale, or null to infer it from the marks.

public ColorScale? ColorScale { get; set; }

Property value

ColorScale?

Coordinates

Plot.cs

Gets or sets the coordinates, or null for the default: polar for arcs (pies, donuts, gauges), Cartesian otherwise.

public Coordinates? Coordinates { get; set; }

Property value

Coordinates?

Description

Plot.cs

Gets or sets the accessible description of the chart (an SVG desc). It is not drawn.

public string? Description { get; set; }

Property value

string?

Facets

Plot.cs

Gets the options of the grid of small charts, when marks have facets (Mark<T>.FacetX, Mark<T>.FacetY).

public FacetOptions Facets { get; }

Property value

FacetOptions

Height

Plot.cs

Gets or sets the height of the chart, in pixels. The default is 400.

public double Height { get; set; }

Property value

double

Exceptions

ArgumentOutOfRangeException
The value is not a positive finite number.

Legend

Plot.cs

Gets the options of the legend of the color scale.

public Legend Legend { get; }

Property value

Legend

Margin

Plot.cs

Gets or sets the space around the plot area, or null to compute it from the axes, the title and the legend.

public ChartMargin? Margin { get; set; }

Property value

ChartMargin?

Marks

Plot.cs

Gets the marks, drawn in order: the first one is at the bottom.

public IList<Mark> Marks { get; }

Property value

IList<Mark>

SecondaryYAxis

Plot.cs

Gets the options of the axis of the secondary y scale. It has no grid lines by default.

public Axis SecondaryYAxis { get; }

Property value

Axis

SecondaryYScale

Plot.cs

Gets or sets the secondary y scale, used by the marks that set Mark.UseSecondaryYScale, or null to infer it from them. In Cartesian coordinates, its axis is on the right of the chart; in transposed and polar coordinates, it has no axis.

public Scale? SecondaryYScale { get; set; }

Property value

Scale?

SizeLegend

Plot.cs

Gets the options of the legend of the size scale, drawn next to the legend of the color scale.

public SizeLegend SizeLegend { get; }

Property value

SizeLegend

SizeScale

Plot.cs

Gets or sets the size scale, or null for the default.

public SizeScale? SizeScale { get; set; }

Property value

SizeScale?

Subtitle

Plot.cs

Gets or sets the subtitle, drawn under the title.

public string? Subtitle { get; set; }

Property value

string?

TextMeasurer

Plot.cs

Gets or sets the measurer of the texts, or null for AfmTextMeasurer.Default.

public ITextMeasurer? TextMeasurer { get; set; }

Property value

ITextMeasurer?

Theme

Plot.cs

Gets or sets the theme. The default is ChartTheme.Light.

public ChartTheme Theme { get; set; }

Property value

ChartTheme

Title

Plot.cs

Gets or sets the title, drawn at the top of the chart and used as its accessible name.

public string? Title { get; set; }

Property value

string?

Width

Plot.cs

Gets or sets the width of the chart, in pixels. The default is 640.

public double Width { get; set; }

Property value

double

Exceptions

ArgumentOutOfRangeException
The value is not a positive finite number.

XAxis

Plot.cs

Gets the options of the axis of the x scale.

public Axis XAxis { get; }

Property value

Axis

XScale

Plot.cs

Gets or sets the x scale, or null to infer it from the marks.

public Scale? XScale { get; set; }

Property value

Scale?

YAxis

Plot.cs

Gets the options of the axis of the y scale.

public Axis YAxis { get; }

Property value

Axis

YScale

Plot.cs

Gets or sets the y scale, or null to infer it from the marks.

public Scale? YScale { get; set; }

Property value

Scale?

Methods

NameDescription
Add(Mark)Adds a mark.
CreateScene(ITextMeasurer?)Lays the chart out into drawing primitives.
ToSvg(SvgRenderOptions?)Returns the chart as SVG.
WriteSvg(Stream, SvgRenderOptions?)Writes the chart as SVG, encoded in UTF-8 without a byte order mark.
WriteSvg(TextWriter, SvgRenderOptions?)Writes the chart as SVG.

Add(Mark)

Plot.cs

Adds a mark.

public Plot Add(Mark mark)

Parameters

mark Mark
The mark.

Returns

Plot The plot, to chain calls.

CreateScene(ITextMeasurer?)

Plot.cs

Lays the chart out into drawing primitives.

public ChartScene CreateScene(ITextMeasurer? textMeasurer = null)

Parameters

textMeasurer ITextMeasurer?
The measurer of the texts, or null for Plot.TextMeasurer.

Returns

ChartScene The scene.

ToSvg(SvgRenderOptions?)

Plot.cs

Returns the chart as SVG.

public string ToSvg(SvgRenderOptions? options = null)

Parameters

options SvgRenderOptions?
The options, or null for the defaults.

Returns

string The SVG document, without an XML declaration.

WriteSvg overloads

WriteSvg(Stream, SvgRenderOptions?)

Plot.cs

Writes the chart as SVG, encoded in UTF-8 without a byte order mark.

public void WriteSvg(Stream stream, SvgRenderOptions? options = null)
Parameters
stream Stream
The destination. It is left open.
options SvgRenderOptions?
The options, or null for the defaults.

WriteSvg(TextWriter, SvgRenderOptions?)

Plot.cs

Writes the chart as SVG.

public void WriteSvg(TextWriter writer, SvgRenderOptions? options = null)
Parameters
writer TextWriter
The destination.
options SvgRenderOptions?
The options, or null for the defaults.