Below you will see a diagram containing three curves.
How can I extract data points from the three colored curves? I need to use the original data.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityBelow you will see a diagram containing three curves.
How can I extract data points from the three colored curves? I need to use the original data.
this code produces the three lists of data that you want orange,blue and green
s = Import["https://i.stack.imgur.com/bR8Gg.gif"];
t = ImageData@s;
h = Union@Flatten[t, 1];
p = FindClusters@h;
F[x_] := (# - {20, 29}) {3/350, 3/100} & /@
Select[Flatten[PixelValuePositions[s, RGBColor[#]] & /@ p[[x]],
1], #[[1]] > 20 && #[[2]] > 29 &]
orange = F[5];
blue = F[1];
green = F[2];
ListPlot[{blue, orange, green}]
Here is the second approach for clustering which was proposed in the comments section
s = Import["https://i.stack.imgur.com/bR8Gg.gif"];
t = ImageData@s;
h = Union@Flatten[t, 1];
p = FindClusters[RGBColor @@@ h];
F[x_] := (# - {21, 29}) {3/350, 3/100} & /@
Select[Flatten[PixelValuePositions[s, #] & /@ p[[x]],
1], #[[1]] > 21 && #[[2]] > 29 &]
orange = F[3];
blue = F[1];
green = F[2];
this gives the same picture but returns more data points in every list
using
Length /@ {blue, orange, green}
first version
{1375, 1228, 1259}
second version
{1534, 1440, 1502}
FindClusters
on lists of 3 numbers vs colors. It works better when it knows it is clustering colors. That is FindClusters[RGBColor @@@ h]
instead of just FindClusters[h]
$\endgroup$
Oct 31, 2018 at 14:15