右轴
新图的每一边都有一个轴。默认情况下,右侧和顶部的轴不可见。要使用右轴,请使其可见,然后告诉 plottable 使用它。
// plot data with very different scales
var sig1 = WpfPlot1.Plot.Add.Signal(Generate.Sin(mult: 0.01));
var sig2 = WpfPlot1.Plot.Add.Signal(Generate.Cos(mult: 100));
// tell each signal plot to use a different axis
sig1.Axes.YAxis = WpfPlot1.Plot.Axes.Left;
sig2.Axes.YAxis = WpfPlot1.Plot.Axes.Right;
// add additional styling options to each axis
WpfPlot1.Plot.Axes.Left.Label.Text = "Left Axis";
WpfPlot1.Plot.Axes.Right.Label.Text = "Right Axis";
WpfPlot1.Plot.Axes.Left.Label.ForeColor = sig1.Color;
WpfPlot1.Plot.Axes.Right.Label.ForeColor = sig2.Color;
WpfPlot1.Refresh();
多轴
可以将其他轴添加到绘图中。默认情况下,绘图表使用主轴的坐标系显示,但任何绘图表都可以使用任何 X 轴和 Y 轴显示。
// plottables use the standard X and Y axes by default
var sig1 = WpfPlot1.Plot.Add.Signal(Generate.Sin(51, mult: 0.01));
sig1.Axes.XAxis = WpfPlot1.Plot.Axes.Bottom; // standard X axis
sig1.Axes.YAxis = WpfPlot1.Plot.Axes.Left; // standard Y axis
WpfPlot1.Plot.Axes.Left.Label.Text = "Primary Y Axis";
// create a second axis and add it to the plot
var yAxis2 = WpfPlot1.Plot.Axes.AddLeftAxis();
// add a new plottable and tell it to use the custom Y axis
var sig2 = WpfPlot1.Plot.Add.Signal(Generate.Cos(51, mult: 100));
sig2.Axes.XAxis = WpfPlot1.Plot.Axes.Bottom; // standard X axis
sig2.Axes.YAxis = yAxis2; // custom Y axis
yAxis2.LabelText = "Secondary Y Axis";
WpfPlot1.Refresh();
仅右轴
默认 Y 轴是绘图左侧的轴,但可以使用右侧 Y 轴。
// add a plottable to the plot
var sig = WpfPlot1.Plot.Add.Signal(Generate.Sin());
// configure the plottable to use the right Y axis
sig.Axes.YAxis = WpfPlot1.Plot.Axes.Right;
// configure the grid to display ticks from the right Y axis
WpfPlot1.Plot.Grid.YAxis = WpfPlot1.Plot.Axes.Right;
// style the right axis as desired
WpfPlot1.Plot.Axes.Right.Label.Text = "Hello, Right Axis";
WpfPlot1.Plot.Axes.Right.Label.FontSize = 18;
// it is recommended to remove tick generators from unused axes
WpfPlot1.Plot.Axes.Left.RemoveTickGenerator();
// pass in the custom axis when calling SetLimits()
WpfPlot1.Plot.Axes.SetLimitsY(bottom: -2, top: 2, yAxis: WpfPlot1.Plot.Axes.Right);
WpfPlot1.Refresh();