SharpPlot Reference > SharpPlot Properties > YCaption Property

SharpPlot.YCaption Property

Sets the Y caption or a pair of captions. The Y-axis caption is written by default vertically alongside the axis.

public string YCaption {get; set;}

Example

sp.YCaption = "Tonnes";

It may also be placed above the top of the axis:

sp.YAxisStyle = YAxisStyles.AtEnd;

This is a better placement for short captions such as ‘mm’ or ‘kg’. Captions written at the top of the axis will be split into multiple lines if you include ‘\n’ in the text, for example ‘Height\n(cm)’ will give a two-line caption. The Caption style controls the alignment of the text for captions placed ‘atend’.

For centred ‘atend’ captions the centred text is wrapped into an effective width of twice the appropriate margin, and left or right aligned text is wrapped into the margin width.

Setting a pair of captions

If you pass a pair of captions separated by the tab character, they are written at the lower and upper ends of the axis.

sp.YCaption = "Cooler\tHotter";

This is a useful technique when the X-axis is vertically centered.


sp.XAxisStyle = XAxisStyles.ArrowedAxis|XAxisStyles.BalancedAxis|XAxisStyles.AtEndCaption;

sp.YCaption = "Cooler\tHotter";
sp.XCaption = "Drier\tMuch\nWetter";

sp.YAxisStyle = YAxisStyles.ArrowedAxis|YAxisStyles.BalancedAxis|YAxisStyles.AtEndCaption;


See also ...

Formatting text with simple HTML tags | SharpPlot Members | SharpPlot.CaptionStyle Property | SharpPlot.YCaptionFormat Property


Send comments on this topic
© Dyalog Ltd 2021