I've been making use of OxyPlot lately, and was wondering if there is a way of overriding the default Color Palette of PlotSeries / PlotModel?
I know i can set the color individually for each series, but it would be nice to have an array of color and then apply it to the model / series.
You can change the DefaultColors
list in PlotView
's Model
:
plotView.Model.DefaultColors = new List<OxyColor>
{
OxyColors.Red,
OxyColors.Green,
OxyColors.Blue,
OxyColor.FromRgb(0x20, 0x4A, 0x87)
};
To make it even more easy, OxyPalettes
's class methods can be used:
plotView.Model.DefaultColors = OxyPalettes.Jet(plotView.Model.Series.Count).Colors;
Adding to the other answer, if you want to use the same set of colors for every plot in your application, you could set those in your xaml resources. If, for instance, you want to use the default Seaborn palette, you could add the following to your 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With