3
$\begingroup$

So I'm using ChromaticityPlot[] to plot some colors as points:

ChromaticityPlot @ {XYZColor[{0.3962764261624673, 0.3985866722291033, 
  0.20513690160842935`}], XYZColor[{0.1882738217108961, 
  0.17432829223539636`, 0.6373978860537075}], XYZColor[{
  0.27512411027344047`, 0.32422074043525423`, 
  0.4006551492913053}], XYZColor[{0.49021477022201715`, 
  0.4671104708306489, 0.042674758947334}], XYZColor[{
  0.2522112854045193, 0.13716125248343866`, 
  0.610627462112042}], XYZColor[{0.21702686377542535`, 
  0.37187565542299844`, 0.41109748080157626`}], XYZColor[{
  0.4519208585586688, 0.4619745394044663, 0.08610460203686487}]}

Which produces:

plot

(I apologize if the points are a little hard to see.)

Is there a way to connect these points in the order of the list they were passed to ChromaticityPlot? If it were something like ListPlot, I'd just used Joined -> True, but it appears that that's not an option for ChromaticityPlot. I checked the Details and Options section of the doc page, but couldn't find anything.

If this isn't possible directly with ChromaticityPlot, my next guess would be doing something where you make a plot of the points and connect them (pretty easy) and then combine that image with a blank ChromaticityPlot such that the points are in the right positions they would be with ChromaticityPlot, but I'm not sure how to do that part smoothly.

edit:

kglr's answer almost works, but I noticed an error when I implemented it. Copying the color coordinates isn't working right now so I've attached pictures. Here are the colors I'm passing to ChromaticityPlot, in this order:

colors

And they produce this plot:

the plot

Basically, they are in the order of the "spiral" you see, which is the order I want the lines to connect them in. But:

Show[cp, Epilog -> Line[Cases[cp, Point[x_] :> x, Infinity]]]

produces:

attempt

So clearly ChromaticityPlot[] indexes the points in its own order when it plots them, and the Epilog code references that order.

How can I plot them in the original order?

Here is the very long list of color coordinates:

{XYZColor[{0.3962764261624673, 0.3985866722291033, 
  0.20513690160842935`}], XYZColor[{0.41989580004282673`, 
  0.4125447180532846, 0.16755948190388859`}], XYZColor[{
  0.4482129325305696, 0.42651818489027327`, 
  0.12526888257915705`}], XYZColor[{0.4811531561718577, 
  0.4381504285364153, 0.08069641529172708}], XYZColor[{
  0.5143601128769091, 0.44025669186403676`, 
  0.04538319525905425}], XYZColor[{0.528760139180238, 
  0.4145525405870635, 0.05668732023269851}], XYZColor[{
  0.4803629345878539, 0.3360211576923957, 
  0.18361590771975042`}], XYZColor[{0.35750986685641445`, 
  0.22882116488660556`, 0.41366896825698}], XYZColor[{
  0.2476518543205762, 0.16907253110576892`, 
  0.5832756145736548}], XYZColor[{0.19861762041302972`, 
  0.1634606041596999, 0.6379217754272702}], XYZColor[{
  0.1875416285273102, 0.1788798412802935, 
  0.6335785301923963}], XYZColor[{0.19135310967885746`, 
  0.19759559604937496`, 0.6110512942717676}], XYZColor[{
  0.199758020524691, 0.2145677412332461, 
  0.5856742382420629}], XYZColor[{0.20906919798555915`, 
  0.2292323092320303, 0.5616984927824105}], XYZColor[{
  0.21820602877387354`, 0.24226526538569332`, 
  0.5395287058404332}], XYZColor[{0.22708567876240668`, 
  0.2546217373697826, 0.5182925838678107}], XYZColor[{
  0.23602526621541525`, 0.2672649432218379, 
  0.49670979056274667`}], XYZColor[{0.24551029106977174`, 
  0.2810589158427847, 0.47343079308744357`}], XYZColor[{
  0.2560852349903017, 0.2966741794557585, 
  0.4472405855539397}], XYZColor[{0.2682779238951681, 
  0.31448277231441685`, 0.4172393037904151}], XYZColor[{
  0.2825298023422926, 0.3344663811508697, 
  0.3830038165068378}], XYZColor[{0.2991300743797761, 
  0.3561737959379507, 0.34469612968227326`}], XYZColor[{
  0.31816383976198165`, 0.37875569437249934`, 
  0.3030804658655192}], XYZColor[{0.3394882438812166, 
  0.4010818563300672, 0.2594298997887162}], XYZColor[{
  0.36274481654029095`, 0.4219134037447116, 
  0.21534177971499754`}], XYZColor[{0.3874012070007992, 
  0.44007475578212696`, 0.1725240372170738}], XYZColor[{
  0.4127991754914565, 0.454565651550761, 
  0.13263517295778254`}], XYZColor[{0.43817789531082135`, 
  0.4645780300397474, 0.09724407464943127}], XYZColor[{
  0.4626457533061279, 0.4694204554873389, 
  0.06793379120653323}], XYZColor[{0.48508605343546224`, 
  0.46838431965922356`, 0.04652962690531424}], XYZColor[{
  0.504000013354655, 0.4606063756512746, 
  0.03539361099407013}], XYZColor[{0.5173231956248223, 
  0.4450040365334342, 0.037672767841743386`}], XYZColor[{
  0.5223206336107772, 0.4203977920883609, 
  0.057281574300861685`}], XYZColor[{0.5157833773795454, 
  0.3859716213212005, 0.09824500129925415}], XYZColor[{
  0.49484180809674294`, 0.3421568586717254, 
  0.16300133323153168`}], XYZColor[{0.45851571455902984`, 
  0.29167965340615476`, 0.24980463203481543`}], XYZColor[{
  0.4093472781509597, 0.23992274244067863`, 
  0.3507299794083615}], XYZColor[{0.3536007952377925, 
  0.19366703703382868`, 0.4527321677283788}], XYZColor[{
  0.29912267846630747`, 0.15855576989396697`, 
  0.5423215516397255}], XYZColor[{0.2522112854045193, 
  0.13716125248343866`, 0.610627462112042}]}
$\endgroup$
  • 1
    $\begingroup$ Show[cp, Epilog->Line[Cases[cp, Point[x_]:>x, Infinity]]]? $\endgroup$ – kglr May 11 '16 at 18:19
  • $\begingroup$ To post the colors you have, select the list of colors and then right-click: Copy As > Input Text. $\endgroup$ – J. M. will be back soon May 12 '16 at 5:38
3
$\begingroup$

Update: To connect the points in the original order, use ChromaticityPlot separately for each color, extract the projected coordinates and combine them:

pts=Sequence@@@(ChromaticityPlot[#,Appearance->None][[1,2,1,2]]&/@colors);
Show[cp, Epilog->{Thick,Line[pts,VertexColors->colors]} ]

Mathematica graphics

Using OP's new list of colors, we get

Mathematica graphics


Original post:

colors= {XYZColor[{0.3962764261624673, 0.3985866722291033, 
  0.20513690160842935`}], XYZColor[{0.1882738217108961, 
  0.17432829223539636`, 0.6373978860537075}], XYZColor[{
  0.27512411027344047`, 0.32422074043525423`, 
  0.4006551492913053}], XYZColor[{0.49021477022201715`, 
  0.4671104708306489, 0.042674758947334}], XYZColor[{
  0.2522112854045193, 0.13716125248343866`, 
  0.610627462112042}], XYZColor[{0.21702686377542535`, 
  0.37187565542299844`, 0.41109748080157626`}], XYZColor[{
  0.4519208585586688, 0.4619745394044663, 0.08610460203686487}]};

cp= ChromaticityPlot[colors];


Show[cp, Epilog->Line[Cases[cp, Point[x_]:>x, Infinity]]]

Mathematica graphics

Show[cp, Epilog->{Thick,Line[Cases[cp, Point[x_]:>x, Infinity], 
                  VertexColors->(Join@@(Partition[colors,2,1]))]}]

Mathematica graphics

$\endgroup$
  • $\begingroup$ I'm out of votes, so here's a suggestion: how about using the specified colors as VertexColors for the line? $\endgroup$ – J. M. will be back soon May 11 '16 at 18:24
  • $\begingroup$ @J.M. good idea; i will try. $\endgroup$ – kglr May 11 '16 at 18:25
  • $\begingroup$ Excellent, this works brilliantly! $\endgroup$ – YungHummmma May 11 '16 at 18:31
  • $\begingroup$ Wait, I'm sorry, I have to un-accept this answer: I was actually implementing this and realized it's not totally right! It connects the points, but based on the order ChromaticityPlot has them in, not the order they were passed to it in! I've edited my OP to reflect the problem. $\endgroup$ – YungHummmma May 12 '16 at 5:23
  • $\begingroup$ @YungHummmma, please see the update. $\endgroup$ – kglr May 12 '16 at 8:38
4
$\begingroup$

By manually converting the XYZColor[] colors into xy, we can generate the line easily.

cols = {XYZColor[...], ...}; (* your list of colors *)

ChromaticityPlot[cols, Epilog -> {Thick, Line[Most[Normalize[#, Total]] & @@@ cols,
                                              VertexColors -> cols]}]

chromaticity diagram with joined points

If the colors given are not XYZ colors, use ColorConvert[] first.


For completeness, here is the corresponding 3D plot with joined points:

Show[ChromaticityPlot3D[cols, PlotStyle -> PointSize[Medium]], 
     Graphics3D[{Thick, Line[Prepend[Most[Normalize[#, Total]], #[[2]]] & @@@ cols, 
                             VertexColors -> cols]}]]

3D chromaticity diagram with joined points

$\endgroup$

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.