2
$\begingroup$

Once, I have made some plots with Mathematica using the ColorData["RedBlueTones"]. Now I want to use the some ColorData in Origin. The Palette-Editor in Origin isn't very helpful and unfortuneately exporting the ColorData from Mathematica directly into the *.pal file-Extension (the only option to load a palette into origin) isn't possible as far as I know. Can anyone give me a hint, how to circumvent that problem or even better how to get any solution for this?

Thanks in advance!

$\endgroup$
  • $\begingroup$ Do you understand the structure of this .pal format and can you explain it in your question? $\endgroup$ – Szabolcs Mar 26 '17 at 17:52
  • $\begingroup$ Unfortunately I cannot... Opening such a file with Editor is not readable. I fear this is my problem. But searching the internet didn't provide me with usefull answers. $\endgroup$ – Kay Mar 26 '17 at 17:56
  • $\begingroup$ @Szabolcs In Origin-Help is mentioned: "You can create new palettes using any external application that writes the palette out in the Microsoft .PAL Format" $\endgroup$ – Kay Mar 26 '17 at 18:01
  • $\begingroup$ Try this: willperone.net/Code/codereadingpal.php or this: worms2d.info/Palette_file. I guess you can create this sort of file using BinaryWrite. $\endgroup$ – Oleksandr R. Mar 26 '17 at 19:47
  • $\begingroup$ ColorData["RedBlueTones", "BlendArgument"] might help; this will return the list of colors that Mathematica interpolates over for the gradient. $\endgroup$ – J. M. is away Mar 27 '17 at 1:02
1
$\begingroup$

See here, the code with this link works http://community.wolfram.com/groups/-/m/t/1061777?p_p_auth=jNhF9gaE

Copying from this answer by Sander Huisman we have:

SetDirectory[NotebookDirectory[]];
ClearAll[ExportPal]
ExportPal[fnout_String,colors_List]:=Module[{colorout,length,str},colorout=Select[colors,ColorQ];
    If[Length[colorout]>0,
        colorout=List@@@(ColorConvert[#,"RGB"]&/@colorout);
        colorout=Take[#,3]&/@colorout; (* remove alpha channel if present *)
        colorout=Append[0]/@Round[255 colorout];
        length=4+4+4+4+2+2+4Length[colors];
        str=OpenWrite[fnout,BinaryFormat->True];
        BinaryWrite[str,"RIFF"];
        BinaryWrite[str,length,"Integer32"];
        BinaryWrite[str,"PAL "];
        BinaryWrite[str,"data"];
        BinaryWrite[str,4Length[colors]+4,"Integer32"];
        BinaryWrite[str,16^^0300,"Integer16"];
        BinaryWrite[str,Length[colors],"Integer16"];
        BinaryWrite[str,Join@@colorout,"Byte"];
        Close[str]
    ,
        Print["plz check z colors, something wrong! kthxbye!"];
        Abort[]
    ]
]
ExportPal["out.pal",{RGBColor[0.5,0.1,0.8,0.1],Blue,Green,LABColor[0.33,-0.48,-0.54]}]
$\endgroup$
  • 5
    $\begingroup$ Link-only answers are not very useful here (even if they are Community links). Please, at the very least, summarize the content of what you're linking to, or (even better) encourage the user there who replied with code to post it here. $\endgroup$ – J. M. is away Apr 14 '17 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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