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.
The code itself that adds the color gradient is
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[DataPaclets`ColorDataDump`colorSchemes, new2];
AppendTo[DataPaclets`ColorDataDump`colorSchemeNames, new2[[1, 1]]];
Its first output is
AppendTo::rvalue: DataPaclets`ColorDataDump`colorSchemes is not a variable with a value, so its value cannot be changed.
AppendTo::rvalue: DataPaclets`ColorDataDump`colorSchemeNames 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!
ColorData;
somewhere in your code before you callAppendTo
. This should force loading of the data structures necessary. $\endgroup$ – MarcoB Jun 13 '18 at 18:34Pick::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.
. $\endgroup$ – M.O. Jun 13 '18 at 19:10