ScottPlot.NET其他设置

数据区背景图像

图像可用于数据区的背景。

  

Miscellaneous.cs

// plot sample data
var sig1 = WpfPlot1.Plot.Add.Signal(Generate.Sin());
var sig2 = WpfPlot1.Plot.Add.Signal(Generate.Cos());
sig1.LineWidth = 3;
sig2.LineWidth = 3;

// One could load an image from a file...
// Image bgImage = new("background.png");

// But in this example we will use a sample image:
Image bgImage = SampleImages.ScottPlotLogo();
WpfPlot1.Plot.DataBackground.Image = bgImage;

WpfPlot1.Refresh();


图 背景 图像

图像可以用作图形的背景。

  

Miscellaneous.cs

// plot sample data
var sig1 = WpfPlot1.Plot.Add.Signal(Generate.Sin());
var sig2 = WpfPlot1.Plot.Add.Signal(Generate.Cos());

// One could load an image from a file...
// Image bgImage = new("background.png");

// But in this example we will use a sample image:
Image bgImage = SampleImages.MonaLisa();
WpfPlot1.Plot.FigureBackground.Image = bgImage;

// Color the axes and data so they stand out against the dark background
WpfPlot1.Plot.Axes.Color(Colors.White);
sig1.Color = sig1.Color.Lighten(.2);
sig2.Color = sig2.Color.Lighten(.2);
sig1.LineWidth = 3;
sig2.LineWidth = 3;

// Shade the data area to make it stand out
WpfPlot1.Plot.DataBackground.Color = Colors.Black.WithAlpha(.5);

WpfPlot1.Refresh();


颜色插值

可以混合颜色以创建一系列颜色。此策略使用线性 RGB 插值。

  

Miscellaneous.cs

for (int i = 0; i <= 10; i++)
{
    double fraction = (double)i / 10;
    double x = i;
    double y = Math.Sin(Math.PI * 2 * fraction);
    var circle = WpfPlot1.Plot.Add.Circle(x, y, 2);
    circle.FillColor = Colors.Blue.MixedWith(Colors.Green, fraction);
    circle.LineColor = Colors.Black.WithAlpha(.5);
}

WpfPlot1.Refresh();


自定义字体文件

用户可以通过从字体文件加载来应用自定义字体。

  

Miscellaneous.cs

// Add a font file to use its typeface for fonts with a given name
Fonts.AddFontFile(
    name: "Alumni Sans",
    path: Path.Combine(Paths.FontFolder, @"AlumniSans/AlumniSans-Regular.ttf"));

// plot sample data
var sig1 = WpfPlot1.Plot.Add.Signal(Generate.Sin(51));
sig1.LegendText = "Sin";
var sig2 = WpfPlot1.Plot.Add.Signal(Generate.Cos(51));
sig2.LegendText = "Cos";

// custom fonts may be used in legends
WpfPlot1.Plot.Legend.FontName = "Alumni Sans";
WpfPlot1.Plot.Legend.FontSize = 24;

// custom fonts may be used in plottables that contain text
var text = WpfPlot1.Plot.Add.Text("Hello", 25, 0.5);
text.LabelStyle.FontName = "Alumni Sans";
text.LabelStyle.FontSize = 24;

// Custom fonts may be used for axis labels.
// Note that bold is disabled because support for
// bold would require loading an additional font file.
WpfPlot1.Plot.Title("Custom Font Demo");
WpfPlot1.Plot.Axes.Title.Label.FontName = "Alumni Sans";
WpfPlot1.Plot.Axes.Title.Label.FontSize = 36;
WpfPlot1.Plot.Axes.Title.Label.Bold = false;

WpfPlot1.Plot.XLabel("Horizontal Axis");
WpfPlot1.Plot.Axes.Bottom.Label.FontName = "Alumni Sans";
WpfPlot1.Plot.Axes.Bottom.Label.FontSize = 24;
WpfPlot1.Plot.Axes.Bottom.Label.Bold = false;

WpfPlot1.Plot.YLabel("Vertical Axis");
WpfPlot1.Plot.Axes.Left.Label.FontName = "Alumni Sans";
WpfPlot1.Plot.Axes.Left.Label.FontSize = 24;
WpfPlot1.Plot.Axes.Left.Label.Bold = false;

WpfPlot1.Refresh();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

code_shenbing

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值