# User Defined Color Scheme in a Package

I have a package that is destined to plot stuff. The plots can have as many functions as the user wants so the variety of the color in the plots has to be enough. Which is why I created a new color gradient as it was explained in this question.

Unprotect[ColorData];
Clear[new2];
new2 = {{"Hueeee", "", {}}, {"Gradients"},
1, {0, 1}, {Hue[0.33, 1, 0.58], Hue[0.6, 1, 0.9],
RGBColor[0.471412, 0.108766, 0.527016], Hue[0.9, 1, 0.9],
Hue[1, 1, 0.9], Hue[0.1, 1, 0.9]}, ""};
AppendTo[DataPacletsColorDataDumpcolorSchemes, new2];
AppendTo[DataPacletsColorDataDumpcolorSchemeNames, new2[[1, 1]]];

Its first output is

AppendTo::rvalue: DataPacletsColorDataDumpcolorSchemes is not a variable with a value, so its value cannot be changed.
AppendTo::rvalue: DataPacletsColorDataDumpcolorSchemeNames is not a variable with a value, so its value cannot be changed.

And the user-defined color data doesn't exist. If I run that code again it creates the color data as intended.

My question is, first, how can I make it so that running that code only once will create my color scheme? And second, how can I make it so the color scheme is added as soon as the package is imported? My understanding is that you put definition of functions inside Private, but I don't know if you actually write commands so that they are run and imported back to the notebook.

Thanks!

• It's probably because something is only loaded on-demand. To force loading, add e.g. ColorData; somewhere in your code before you call AppendTo. This should force loading of the data structures necessary. – MarcoB Jun 13 '18 at 18:34
• That doesnt seem to do anything. I cant get the new gradient to be added, instead this message appears Pick::incomp: Expressions {<<1>>} and {Atoms,Crayola,GeologicAges,HTML,Legacy,WebSafe,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,<<198>>} have incompatible shapes.. – M.O. Jun 13 '18 at 19:10

Your initial problem was due to the autoloading done by ColorData, as suggested by @MarcoB. The subsequent issue, which you only mention in the comments, is that both:

DataPacletsColorDataDumpcolorSchemes
DataPacletsColorDataDumpcolorSchemeNames

are also auto-loaded, and you need to finish the auto-loading before you try to append to the symbols. So, the following should do what you want:

ColorData[];
DataPacletsColorDataDumpcolorSchemes;
DataPacletsColorDataDumpcolorSchemeNames;

Unprotect[ColorData];
Clear[new2];
new2 = {
{"Hueeee", "", {}},
1,
{0,1},
{
Hue[0.33,1,0.58], Hue[0.6,1,0.9], RGBColor[0.471412,0.108766,0.527016],
Hue[0.9,1,0.9], Hue[1,1,0.9], Hue[0.1,1,0.9]
},
""
};
AppendTo[DataPacletsColorDataDumpcolorSchemes,new2];
AppendTo[DataPacletsColorDataDumpcolorSchemeNames,new2[[1,1]]];

I didn't get any errors, and: