0
$\begingroup$

I have created a custom Entry in ColorData as described by Mr. Wizard in this Question

This works well until I need to force the Scaling of the ColorFunction to compare to other images.

A simple example would be:

DensityPlot[Sin[x y]*3, {x, 0, 3}, {y, 0, 3}, 
ColorFunction -> ColorData[{"Rainbow", {0, 3}}], 
ColorFunctionScaling -> False, PlotPoints -> 200, 
PlotLegends -> Automatic]

Giving the following image:

enter image description here

But a new color set "Test", defined through:

ColorData[1];

new = {{"Test", "", {}}, {"Gradients"}, 
1, {0, 1}, {RGBColor[0, 0, 1], RGBColor[0, 1, 1], 
RGBColor[0, 1, 0], RGBColor[1, 1, 0], RGBColor[1, 0, 0]}, ""};

AppendTo[DataPaclets`ColorDataDump`colorSchemes, new];

AppendTo[DataPaclets`ColorDataDump`colorSchemeNames, new[[1, 1]]];

does not allow formatting along the lines of ColorData[{"Test",{min,max}}], resulting in:

ColorData::notent: {Test,{0,3}} is not a known entity, class, or tag for ColorData. Use ColorData[] for a list of entities.

How can I force a certain scaling on a Custom ColorData function?

This Syntax using {min,max} was very convenient, as I could write functions with scaling defined through MinMax[data].

$\endgroup$

1 Answer 1

2
$\begingroup$

Creating a pure function with Rescale[] fixed it in the end.

DensityPlot[Sin[x y]*3, {x, 0, 3}, {y, 0, 3}, 
ColorFunction -> (ColorData["Test", Rescale[#1, {0, 3}]] &),
ColorFunctionScaling -> False, PlotPoints -> 200, PlotLegends -> Automatic]

plot

Though I'm still wondering why the inserted ColorData does not share the same properties as the default ones.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.