我最近一直在使用OxyPlot,想知道是否有办法覆盖 PlotSeries / PlotModel 的默认调色板?
我知道我可以为每个系列单独设置颜色,但是拥有一组颜色然后将其应用于模型/系列会很好。
我最近一直在使用OxyPlot,想知道是否有办法覆盖 PlotSeries / PlotModel 的默认调色板?
我知道我可以为每个系列单独设置颜色,但是拥有一组颜色然后将其应用于模型/系列会很好。
您可以更改'sDefaultColors
中的列表:PlotView
Model
plotView.Model.DefaultColors = new List<OxyColor>
{
OxyColors.Red,
OxyColors.Green,
OxyColors.Blue,
OxyColor.FromRgb(0x20, 0x4A, 0x87)
};
为了使它更容易,OxyPalettes
可以使用 的类方法:
plotView.Model.DefaultColors = OxyPalettes.Jet(plotView.Model.Series.Count).Colors;
添加到另一个答案中,如果您想为应用程序中的每个绘图使用相同的颜色集,您可以在您的 xaml 资源中设置这些颜色。例如,如果您想使用默认的Seaborn 调色板,您可以将以下内容添加到您的App.xaml
:
<Application.Resources>
<ResourceDictionary>
<x:Array Type="Color" x:Key="SeabornColors">
<Color>#4c72b0</Color>
<Color>#55a868</Color>
<Color>#c44e52</Color>
<Color>#8172b2</Color>
<Color>#ccb974</Color>
<Color>#64b5cd</Color>
</x:Array>
<Style TargetType="oxy:Plot">
<Setter Property="DefaultColors" Value="{StaticResource SeabornColors}"/>
</Style>
</ResourceDictionary>
</Application.Resources>