10

我最近一直在使用OxyPlot,想知道是否有办法覆盖 PlotSeries / PlotModel 的默认调色板?

我知道我可以为每个系列单独设置颜色,但是拥有一组颜色然后将其应用于模型/系列会很好。

4

2 回答 2

16

您可以更改'sDefaultColors中的列表:PlotViewModel

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;
于 2015-04-24T21:00:57.730 回答
5

添加到另一个答案中,如果您想为应用程序中的每个绘图使用相同的颜色集,您可以在您的 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>
于 2017-03-24T17:42:33.873 回答