In Mathematica, how to superpose two ListLinePlot? - wolfram-mathematica

I was using ListPlot to draw two smooth lines through some data points. But I want to superpose the plot.I learned that the method used by ListPlot for interpolation is to interpolate each coordinate as a function of the list index. So I can not simply plus two
interpolations of my two points.
thanks,
jzm
Here is some text for copy/paste:
myPoints1 = {{1.4620657889458748`,
335.2985577878116`}, {1.4620965802217518`,
103.38351787529564`}, {1.4621942025270345`,
62.5559208248015`}, {1.462354896492246`,
45.566589506360216`}, {1.4625751467402768`,
36.264281440327565`}, {1.4628516301983985`,
30.399003865053114`}, {1.4631812807492346`,
26.367460111951058`}, {1.4635611902991474`,
23.429554855802188`}, {1.4639886111585874`,
21.195443300677702`}, {1.464460983399038`,
19.440829611123966`}, {1.4649759015994719`,
18.02777886500251`}, {1.4655311109490736`,
16.86675689819105`}, {1.466124470097565`,
15.896899417397284`}, {1.4667539758770534`,
15.075547889029616`}, {1.467417728656181`,
14.37183869811537`}, {1.468113935160521`,
13.76291072113658`}, {1.4688409098827062`,
13.231534377122449`}, {1.4695970390339186`,
12.764290193109172`}, {1.4703808152150737`,
12.350655500316538`}, {1.47119080820051`,
11.982259112096562`}, {1.4720256766729714`,
11.652466731657922`}, {1.4728841551349938`,
11.35608813384227`}, {1.4737650210799367`,
11.088805023428025`}, {1.4746670942175184`,
10.846730689594123`}, {1.4755892711659102`,
10.626599181057326`}, {1.4765305432312286`,
10.425844517518913`}, {1.4774899140433866`,
10.242189544437958`}, {1.4784664768294848`,
10.07388845283117`}, {1.4794593535682306`,
9.91948469998374`}, {1.480467656424019`,
9.777491405153027`}, {1.4814906043125302`,
9.646805534544441`}, {1.4825273964568986`,
9.526291139015447`}, {1.4835772786981303`,
9.414764726544572`}, {1.4846395968104766`,
9.311395888282872`}, {1.4857136927436698`,
9.215545785306015`}, {1.4867989654798728`,
9.12678547130485`}, {1.487894785812934`,
9.0445918653539`}, {1.489000547636927`,
8.968341543739935`}, {1.49011571024499`,
7.71616343700933`}, {1.4912397307928495`,
4.4771368717931965`}, {1.4930948425223702`,
2.7599903709003706`}, {1.4972705714803425`, 2.137733395169292`}};
myPoints2 = {{1.9550995254889463,
0.7164793699550908}, {1.9391287471262355,
0.41710931241140287}, {1.9139528821159193,
0.3490726623599497}, {1.884617534719042,
0.3308820126668058}, {1.8540123750258504,
0.33265450551933234}, {1.8237456098779754,
0.3452794413751484}, {1.7946805323610866,
0.36513934480358856}, {1.7672498634600862,
0.3905924543768967}, {1.7416378319498413,
0.42085584504202456}, {1.717886011205134,
0.45557423825820337}, {1.6959554065943552,
0.49463019895914645}, {1.675763216373194,
0.5380524422510392}, {1.6572047192352064,
0.5859687470445493}, {1.6401662975943239,
0.6385812315738714}, {1.6245331447101943,
0.6961532977719818}, {1.6101937002933333,
0.7590036122922289}, {1.5970420916568349,
0.8275045669571167}, {1.5849793700525658,
0.9020832266507519}, {1.5739139593253322,
0.9832255360102758}, {1.5637616875683809,
1.071482155332956}, {1.5544455489784297,
1.1674755467368436}, {1.5458952859916812,
1.2719109855898907}, {1.538046945587126,
1.3855881585132812}, {1.5308423787211705,
1.5094157124835617}, {1.5242287288899015,
1.6444321762294256}, {1.5181579889629853,
1.7918272163885938}, {1.512586535548833,
1.952969437543702}, {1.5074747129386745,
2.1294427702228105}, {1.5027864632086367,
2.3230885849762424}, {1.4984889655043911,
2.536061738604728}, {1.4945523307439923,
2.7708992557015053}, {1.4909493139037207,
3.0306073328297867}, {1.4876550515968234,
3.3187795649748657}, {1.4846468371914137,
3.6397480437107252}, {1.481903916697491,
3.9987774524193394}, {1.4794072959177726,
4.4023273698572325}, {1.4771395719585305,
4.858408392792459}, {1.4750847772800355,
5.37708563628973}, {1.4732282431253443,
5.971204815109932}, {1.4715564902918326,
6.657415608955233}, {1.4700571242943155,
7.457674059555506}, {1.4687187279247118,
8.40154880208839}, {1.4675307832019475,
9.529729255387132}, {1.4664835796976867,
10.899794007715421}, {1.46556811155878,
12.596323274840168}, {1.4647760611386595,
14.748618559900901}, {1.4640997339059703,
17.564564972128032}, {1.463531979901696,
21.401490423013954}, {1.4630661880201312,
26.92897502098747}, {1.462696204020183,
35.566591773864054}, {1.4624163023794263,
50.94289950596402}, {1.462221186527755,
85.91265697099175}, {1.4621058905589708,
243.1565306412274}, {1.4620657889458748, 335.2985577878116}};
what I want is not
Show[ListPlot[myPoints1, Joined -> True, Mesh -> Full],
ListPlot[myPoints2, Joined -> True, Mesh -> Full]]
don't know how to get the plot of the value's superpostion of the two plot.Please help!:)
The meaning of "superpostion" is to get the plus of the value of the two curves at every x-axis.

Sounds like you want something like this in order to "plus" your lines.
it1 = Interpolation[myPoints1];
it2 = Interpolation[myPoints2];
t1 = Table[it1[i], {i, 1.467, 1.497, 0.001}];
t2 = Table[it2[i], {i, 1.467, 1.497, 0.001}];
t3 = Transpose[{Range[1.467, 1.497, 0.001], t1 + t2}];
ListPlot[{myPoints1, myPoints2, t3}, Joined -> True,
PlotRange -> {{1.467, 1.497}, {0, 30}}, PlotMarkers -> Automatic]

Related

getting 6 equally spaced points from a sequence of linestring in python

I have data whose geometry is a sequence of line strings. From this geometry, we intend to obtain 6 equally spaced points. I have tried using the np.linspace and the np.arrange functions but I can't get what I am looking for. Kindly help me with the algorithm for working out this. Below is my geometry:
0 0 [(34.220545045730496, 4.442393531636864), (34.2224155889151, 4.441156322612342), (34.223315935853314, 4.440427900224906), (34.224077028342684, 4.4399257458670185), (34.224766879680814, 4.439278243976972), (34.22556405912324, 4.438776319912429), (34.226398022458866, 4.438165968807749), (34.22734024644533, 4.437556318146236), (34.22943852729713, 4.4365111090884435), (34.23209935027103, 4.435703837269645), (34.234239592861904, 4.434838866278886), (34.23690044724009, 4.434031568657816), (34.238982889400376, 4.4332242366641825), (34.24054473957206, 4.4327052342468), (34.244651946024526, 4.431263497605144), (34.246271748538476, 4.430629103905764), (34.24783374809697, 4.429764000807084), (34.24904866823832, 4.429014226798339), (34.25043718779403, 4.428091408213787), (34.2521728964003,
(34.352324364376926, 4.208738505912754), (34.35256435592366, 4.208668509240028)]
Name: geometry, type: object
I tried this code but still can't get the 25th ,75th pts right.
first_coord = N_df["geometry"].apply(lambda g: g.coords[0])
Point_25th = N_df['geometry'].agg(lambda g: np.percentile(g, 25))
center_point = N_df['geometry'].centroid
point_75th = N_df['geometry'].agg(lambda g: np.percentile(g, 75))
last_coord = N_df["geometry"].apply(lambda g: g.coords[-1])
N_df["start_coord"] = first_coord
N_df["25th percentile"] = Point_25th
N_df["Midpoint"] = center_point
N_df["75th percentile"] = point_75th
N_df["last_coord"] = last_coord
# N_df ...?

Plotting a list of lines in Mathematica and trimming to an area

I have specified some lines in a list for example
linelist = {Line[{{-390, 1}, {1690, 1}}],
Line[{{-390, 40}, {1690, 40}}], Line[{{-390, 79}, {1690, 79}}],
Line[{{-390, 118}, {1690, 118}}], Line[{{-390, 781}, {1690, 781}}],
Line[{{-390, 820}, {1690, 820}}], Line[{{-390, 859}, {1690, 859}}],
Line[{{-390, 898}, {1690, 898}}], Line[{{-498, 460}, {1185, 1682}}],
Line[{{-521, 491}, {1162, 1714}}],
Line[{{-544, 523}, {1139, 1745}}],
Line[{{-567, 554}, {1116, 1777}}],
Line[{{-590, 586}, {1093, 1809}}],
Line[{{-613, 617}, {1070, 1840}}],
Line[{{-636, 649}, {1047, 1872}}],
Line[{{-659, 681}, {1024, 1903}}],
Line[{{946, -541}, {1588, 1437}}],
Line[{{908, -528}, {1551, 1449}}],
Line[{{871, -517}, {1514, 1462}}],
Line[{{834, -504}, {1477, 1473}}],
Line[{{797, -493}, {1440, 1486}}],
Line[{{760, -481}, {1402, 1498}}],
Line[{{723, -469}, {1366, 1510}}],
Line[{{686, -457}, {1328, 1522}}],
Line[{{1291, -237}, {648, 1741}}],
Line[{{1255, -250}, {611, 1729}}],
Line[{{1217, -261}, {575, 1717}}],
Line[{{1181, -274}, {538, 1705}}],
Line[{{1143, -285}, {501, 1693}}],
Line[{{1107, -296}, {463, 1681}}],
Line[{{1069, -309}, {427, 1668}}],
Line[{{1032, -321}, {389, 1657}}], Line[{{995, -333}, {352, 1646}}],
Line[{{958, -345}, {316, 1633}}],
Line[{{1002, -638}, {-680, 584}}], Line[{{979, -668}, {-703, 553}}]}
Graphics#linelist
I'm trying to figure out a way to iterate through each line to perform a test, for example the distance from the 0,0 coordinate.
Also, the end points are outside of my area of concern. I would like to constrain the lines to a boxed area, say from -1600,-1600 to 1600, 1600
I've been playing with this for hours and trying to make a for loop work for the Line statements, but, then I can't get them back on the same graph.
The plot I get without clipping is:
The plot I get with clipping works for horizontal lines, but, the slanted lines are no longer parallel. (from suggested answer below)
newlinelist = Map[({{x1, y1}, {x2, y2}} = #[[1]];
Line[{{Clip[x1, {0, 1300}],
Clip[y1, {0, 1300}]}, {Clip[x2, {0, 1300}],
Clip[y2, {0, 1300}]}}]) &, linelist]
Other kinds of programming languages depend heavily on you writing For loops. It is possible to do that in Mathematica, but there are other ways to do things. For example:
linelist={
Line[{{-390,1},{1690,1}}],Line[{{-390,40},{1690,40}}],Line[{{-390,79},{1690,79}}],
Line[{{-390,118},{1690,118}}],Line[{{-390,781},{1690,781}}],Line[{{-390,820},{1690,820}}],
Line[{{-390,859},{1690,859}}],Line[{{-390,898},{1690,898}}],Line[{{-498,460},{1185,1682}}],
Line[{{-521,491},{1162,1714}}],Line[{{-544,523},{1139,1745}}],Line[{{-567,554},{1116,1777}}],
Line[{{-590,586},{1093,1809}}],Line[{{-613,617},{1070,1840}}],Line[{{-636,649},{1047,1872}}],
Line[{{-659,681},{1024,1903}}],Line[{{946,-541},{1588,1437}}],Line[{{908,-528},{1551,1449}}],
Line[{{871,-517},{1514,1462}}],Line[{{834,-504},{1477,1473}}],Line[{{797,-493},{1440,1486}}],
Line[{{760,-481},{1402,1498}}],Line[{{723,-469},{1366,1510}}],Line[{{686,-457},{1328,1522}}],
Line[{{1291,-237},{648,1741}}],Line[{{1255,-250},{611,1729}}],Line[{{1217,-261},{575,1717}}],
Line[{{1181,-274},{538,1705}}],Line[{{1143,-285},{501,1693}}],Line[{{1107,-296},{463,1681}}],
Line[{{1069,-309},{427,1668}}],Line[{{1032,-321},{389,1657}}],Line[{{995,-333},{352,1646}}],
Line[{{958,-345},{316,1633}}],Line[{{1002,-638},{-680,584}}],Line[{{979,-668},{-703,553}}]};
newlinelist=Map[({{x1,y1},{x2,y2}}=#[[1]];
Line[{{Clip[x1,{-1600,1600}],Clip[y1,{-1600,1600}]},
{Clip[x2,{-1600,1600}],Clip[y2,{-1600,1600}]}}])&,linelist
]
returns
{Line[{{-390,1},{1600,1}}],Line[{{-390,40},{1600,40}}],Line[{{-390,79},{1600,79}}],
Line[{{-390,118},{1600,118}}],Line[{{-390,781},{1600,781}}],Line[{{-390,820},{1600,820}}],
Line[{{-390,859},{1600,859}}],Line[{{-390,898},{1600,898}}],Line[{{-498,460},{1185,1600}}],
Line[{{-521,491},{1162,1600}}],Line[{{-544,523},{1139,1600}}],Line[{{-567,554},{1116,1600}}],
Line[{{-590,586},{1093,1600}}],Line[{{-613,617},{1070,1600}}],Line[{{-636,649},{1047,1600}}],
Line[{{-659,681},{1024,1600}}],Line[{{946,-541},{1588,1437}}],Line[{{908,-528},{1551,1449}}],
Line[{{871,-517},{1514,1462}}],Line[{{834,-504},{1477,1473}}],Line[{{797,-493},{1440,1486}}],
Line[{{760,-481},{1402,1498}}],Line[{{723,-469},{1366,1510}}],Line[{{686,-457},{1328,1522}}],
Line[{{1291,-237},{648,1600}}],Line[{{1255,-250},{611,1600}}],Line[{{1217,-261},{575,1600}}],
Line[{{1181,-274},{538,1600}}],Line[{{1143,-285},{501,1600}}],Line[{{1107,-296},{463,1600}}],
Line[{{1069,-309},{427,1600}}],Line[{{1032,-321},{389,1600}}],Line[{{995,-333},{352,1600}}],
Line[{{958,-345},{316,1600}}],Line[{{1002,-638},{-680,584}}],Line[{{979,-668},{-703,553}}]}
What that does is use the Map function which takes a list and another
function to apply to each item in that list and it returns a list of the
results. What that function does for your application is extract the x1,y1,x2,y2 values out of your Line and then uses the Mathematica Clip function to constrain the values and finally constructs a new Line with the new values.
That # and & function stuff may be difficult for a new user to understand.
Here is an alternate way of writing that which should do the same thing.
f[Line[{{x1_,y1_},{x2_,y2_}}]]:=Line[{{Clip[x1,{-1600,1600}],Clip[y1,{-1600,1600}]},
{Clip[x2,{-1600,1600}],Clip[y2,{-1600,1600}]}}];
newlinelist=Map[f,linelist]
You should verify that it did correctly trim each of your lines
to lie in the -1600...1600 box that you desired.
I am a little worried about the result. If you compare these two graphics
Graphics[linelist]
Graphics[newlinelist]
you can see that the upper part of those are different and it doesn't seem to just be because of trimming the ranges of x and y. Notice that some of the lines are no longer parallel in the second one. You should try to convince yourself if that is what you really want or not.
A completely different way of getting the different graphic, but without changing the underlying list of lines, is to compare these two
Graphics[linelist]
Graphics[linelist,PlotRange->{{-1600,1600},{-1600,1600}}]
Notice that all the lines remain parallel in the second one.
You wrote that you had tried using PlotRange without success and I think you should study exactly why that didn't work for you and whether this does work for you.

Mathematica - Dynamic - ListPlot - baseline

I am performing baseline fitting to a raw dataset on a two-state equilibrium process. The process involves fitting the sigmoidal curve to an upper and lower linear baseline, and subtracting so that you get a curve going from y=(0) (state 1) to y=(1) (state 2) over your x-value range instead y=(experimental observable values).
I'd like to expedite the baseline selection process through an interactive dynamic approach rather than manually typing in lhs/rhs x-values for each curve. However, I'm noticing that the dynamic values behind the dynamic plots need to be on the screen for the plot to update. Meaning, if I'm dynamic listplotting 4 points, and only three of these dynamic values (the output) are on screen then only three show up. I have to scroll up or down through the notebook to "update" various values and then the plots correct themselves.
I have many calculations downstream after baseline selection, and I'd like to have all these subsequent calculations print up in a neat little grid near the sliders, without have to scroll.
I'm new to Dynamic, and also having trouble combining multiple plots (similar to Show) when held under the Dynamic functions. I'd like to dynamically in one graphic plot the ListPlot of my rawData, the four baseline points, and then the fitted linear function through the selected rawData in the baseline area. Next to this, I'll plot the two-state equilibrium plot (y=0 to 1) and then a single point representing the transition point of 50/50 state1/state2 (y=0.5). All of these downstream processes are highly dependent on baseline selection, so I'd like to have the slider there and final plots to immediately see the results of various choices for baselines.
In summary, two questions:
1) screen refresh needed of output from dynamic values for updating dynamic plots not in the same input section
2) multiple plot types within a single graphic, dynamically
Best regards,
Kurtis
ramp1FCelsiusXRFUSmooth[
1] = {{5.2, 171.5576923076923}, {5.4, 171.4583916083916}, {5.6,
171.36804195804197}, {5.8, 171.31552447552448}, {6,
171.31125874125877}, {6.2, 171.35321678321677}, {6.4,
171.41783216783216}, {6.6, 171.5072027972028}, {6.8,
171.61223776223778}, {7, 171.74020979020978}, {7.2,
171.8802097902098}, {7.4, 172.01412587412588}, {7.6,
172.1367832167832}, {7.8, 172.25818181818184}, {8,
172.37916083916082}, {8.2, 172.52223776223775}, {8.4,
172.65797202797202}, {8.6, 172.81475524475525}, {8.8,
172.97706293706293}, {9, 173.16314685314686}, {9.2,
173.35531468531468}, {9.4, 173.56958041958043}, {9.6,
173.7951048951049}, {9.8, 174.03153846153847}, {10,
174.2748951048951}, {10.2, 174.51762237762236}, {10.4,
174.7634265734266}, {10.6, 174.9851048951049}, {10.8,
175.1865034965035}, {11, 175.3864335664336}, {11.2,
175.59503496503498}, {11.4, 175.81916083916082}, {11.6,
176.02797202797203}, {11.8, 176.2442657342657}, {12,
176.45391608391608}, {12.2, 176.6886013986014}, {12.4,
176.9281118881119}, {12.6, 177.19}, {12.8, 177.47}, {13,
177.7390909090909}, {13.2, 178.01503496503494}, {13.4,
178.2923076923077}, {13.6, 178.60461538461539}, {13.8,
178.92685314685315}, {14, 179.24713286713288}, {14.2,
179.5781818181818}, {14.4, 179.93076923076922}, {14.6,
180.32083916083917}, {14.8, 180.71741258741258}, {15,
181.124965034965}, {15.2, 181.55125874125875}, {15.4,
181.97825174825175}, {15.6, 182.41020979020982}, {15.8,
182.8441258741259}, {16, 183.3011188811189}, {16.2,
183.77636363636367}, {16.4, 184.26951048951048}, {16.6,
184.80447552447555}, {16.8, 185.37951048951047}, {17,
185.97846153846154}, {17.2, 186.58356643356643}, {17.4,
187.19545454545454}, {17.6, 187.81587412587407}, {17.8,
188.44538461538463}, {18, 189.08426573426573}, {18.2,
189.73111888111887}, {18.4, 190.38111888111888}, {18.6,
191.04258741258744}, {18.8, 191.7199300699301}, {19,
192.43076923076922}, {19.2, 193.16111888111888}, {19.4,
193.91048951048953}, {19.6, 194.68713286713282}, {19.8,
195.4913286713287}, {20, 196.32006993006993}, {20.2,
197.17510489510488}, {20.4, 198.05881118881118}, {20.6,
198.95755244755247}, {20.8, 199.8584615384615}, {21,
200.76384615384615}, {21.2, 201.68461538461537}, {21.4,
202.62685314685316}, {21.6, 203.66496503496504}, {21.8,
204.81300699300698}, {22, 205.96062937062936}, {22.2,
206.8897902097902}, {22.4, 207.50202797202797}, {22.6,
207.81699300699304}, {22.8, 207.95888111888112}, {23,
208.02839160839162}, {23.2, 208.14692307692306}, {23.4,
208.4265734265734}, {23.6, 208.94608391608392}, {23.8,
209.81937062937064}, {24, 211.1255244755245}, {24.2,
212.82013986013985}, {24.4, 214.7145454545455}, {24.6,
216.61958041958042}, {24.8, 218.50860139860137}, {25,
220.42069930069928}, {25.2, 222.4111888111888}, {25.4,
224.48314685314682}, {25.6, 226.616013986014}, {25.8,
228.8025874125874}, {26, 231.0102097902098}, {26.2,
233.26111888111888}, {26.4, 235.54636363636362}, {26.6,
237.8906293706294}, {26.8, 240.30881118881118}, {27,
242.80363636363634}, {27.2, 245.37720279720278}, {27.4,
248.0467132867133}, {27.6, 250.82118881118885}, {27.8,
253.69622377622377}, {28, 256.65937062937064}, {28.2,
259.7168531468531}, {28.4, 262.8809090909091}, {28.6,
266.136083916084}, {28.8, 269.48853146853145}, {29,
272.9494405594406}, {29.2, 276.5634265734266}, {29.4,
280.31496503496504}, {29.6, 284.1983916083916}, {29.8,
288.2063636363637}, {30, 292.3523076923077}, {30.2,
296.6392307692308}, {30.4, 301.0708391608391}, {30.6,
305.62391608391613}, {30.8, 310.3113286713287}, {31,
315.11034965034963}, {31.2, 320.04965034965034}, {31.4,
325.1569230769231}, {31.6, 330.4420979020979}, {31.8,
335.90902097902097}, {32, 341.55034965034963}, {32.2,
347.37482517482516}, {32.4, 353.38538461538457}, {32.6,
359.5694405594406}, {32.8, 365.93888111888117}, {33,
372.4761538461538}, {33.2, 379.2182517482518}, {33.4,
386.1609790209791}, {33.6, 393.32629370629365}, {33.8,
400.7041958041958}, {34, 408.26265734265735}, {34.2,
416.02657342657346}, {34.4, 423.96489510489516}, {34.6,
432.1181818181819}, {34.8, 440.4820979020979}, {35,
448.6806293706294}, {35.2, 456.86342657342664}, {35.4,
465.53755244755246}, {35.6, 475.66034965034964}, {35.8,
487.5865734265734}, {36, 501.1653146853147}, {36.2,
516.0813286713288}, {36.4, 531.9086013986014}, {36.6,
548.2587412587412}, {36.8, 564.6713986013987}, {37,
580.6118881118881}, {37.2, 595.7270629370629}, {37.4,
609.4006293706293}, {37.6, 622.2286013986014}, {37.8,
634.5355944055943}, {38, 647.2777622377623}, {38.2,
660.156153846154}, {38.4, 673.3221678321679}, {38.6,
686.4862237762237}, {38.8, 699.9664335664336}, {39,
713.5155244755244}, {39.2, 727.4389510489511}, {39.4,
741.0336363636363}, {39.6, 755.0702097902098}, {39.8,
769.5217482517482}, {40, 785.5246153846156}, {40.2,
802.3835664335664}, {40.4, 820.4558741258742}, {40.6,
838.8953146853147}, {40.8, 858.1897202797202}, {41,
877.5658741258741}, {41.2, 897.573986013986}, {41.4,
917.3868531468532}, {41.6, 937.4052447552448}, {41.8,
956.7482517482517}, {42, 976.6904895104893}, {42.2,
997.0346153846153}, {42.4, 1018.8477622377623}, {42.6,
1041.1142657342657}, {42.8, 1064.3213286713287}, {43,
1088.1560139860142}, {43.2, 1112.473986013986}, {43.4,
1137.4900699300697}, {43.6, 1164.0341958041959}, {43.8,
1192.6026573426573}, {44, 1223.4609090909091}, {44.2,
1255.9941258741258}, {44.4, 1290.8709790209791}, {44.6,
1327.0130769230768}, {44.8, 1364.6239860139858}, {45,
1402.7880419580417}, {45.2, 1442.381118881119}, {45.4,
1482.7290909090907}, {45.6, 1523.66013986014}, {45.8,
1565.570979020979}, {46, 1609.5718881118883}, {46.2,
1656.1732867132866}, {46.4, 1705.5791608391607}, {46.6,
1757.082797202797}, {46.8, 1811.405664335664}, {47,
1867.7601398601398}, {47.2, 1927.0214685314686}, {47.4,
1988.903566433566}, {47.6, 2053.9727272727273}, {47.8,
2121.3558741258735}, {48, 2191.253076923077}, {48.2,
2263.4567132867137}, {48.4, 2338.992097902097}, {48.6,
2417.6206293706296}, {48.8, 2499.507062937063}, {49,
2584.0679020979014}, {49.2, 2672.40048951049}, {49.4,
2764.2509090909093}, {49.6, 2860.08972027972}, {49.8,
2958.8880419580414}, {50, 3061.5296503496506}, {50.2,
3167.954475524476}, {50.4, 3279.3267132867136}, {50.6,
3394.996363636363}, {50.8, 3514.5386013986017}, {51,
3637.8941958041955}, {51.2, 3767.8172727272727}, {51.4,
3907.369160839161}, {51.6, 4057.940839160839}, {51.8,
4218.387692307691}, {52, 4387.486363636363}, {52.2,
4559.219090909091}, {52.4, 4737.994405594407}, {52.6,
4926.850629370629}, {52.8, 5133.069790209789}, {53,
5351.979300699301}, {53.2, 5580.233216783217}, {53.4,
5815.771258741259}, {53.6, 6059.474335664335}, {53.8,
6310.2300699300695}, {54, 6566.168951048951}, {54.2,
6824.079510489511}, {54.4, 7080.809090909091}, {54.6,
7333.146293706293}, {54.8, 7587.8459440559445}, {55,
7850.626853146852}, {55.2, 8125.57027972028}, {55.4,
8409.073496503495}, {55.6, 8698.83132867133}, {55.8,
8996.236433566435}, {56, 9300.716293706295}, {56.2,
9614.424195804197}, {56.4, 9936.465874125875}, {56.6,
10267.16895104895}, {56.8, 10604.112797202795}, {57,
10948.749580419582}, {57.2, 11300.41020979021}, {57.4,
11659.683006993006}, {57.6, 12023.626783216785}, {57.8,
12392.80202797203}, {58, 12766.768741258744}, {58.2,
13147.152517482516}, {58.4, 13533.405594405594}, {58.6,
13929.522447552448}, {58.8, 14331.496503496504}, {59,
14735.11027972028}, {59.2, 15134.907552447552}, {59.4,
15531.639090909091}, {59.6, 15926.898251748251}, {59.8,
16319.009370629366}, {60, 16708.945804195802}, {60.2,
17100.06636363636}, {60.4, 17496.746923076924}, {60.6,
17899.96601398601}, {60.8, 18310.962377622378}, {61,
18733.114335664337}, {61.2, 19158.742027972025}, {61.4,
19578.491538461538}, {61.6, 19983.563636363637}, {61.8,
20383.41286713287}, {62, 20771.78615384616}, {62.2,
21143.815874125874}, {62.4, 21493.19979020979}, {62.6,
21831.533146853144}, {62.8, 22165.208671328666}, {63,
22497.004265734264}, {63.2, 22829.18895104895}, {63.4,
23165.61839160839}, {63.6, 23505.106223776227}, {63.8,
23845.65895104895}, {64, 24185.918321678324}, {64.2,
24530.909580419582}, {64.4, 24870.472797202798}, {64.6,
25198.522797202797}, {64.8, 25507.47804195804}, {65,
25802.223846153847}, {65.2, 26082.483426573428}, {65.4,
26348.033426573424}, {65.6, 26600.166853146857}, {65.8,
26840.285384615385}, {66, 27072.183286713287}, {66.2,
27294.89937062937}, {66.4, 27510.708951048953}, {66.6,
27720.160139860138}, {66.8, 27922.566853146855}, {67,
28118.26083916084}, {67.2, 28307.706083916084}, {67.4,
28494.77258741259}, {67.6, 28679.58657342657}, {67.8,
28860.11972027972}, {68, 29039.42153846154}, {68.2,
29210.7306993007}, {68.4, 29366.41545454545}, {68.6,
29502.546223776226}, {68.8, 29629.67433566434}, {69,
29744.836363636365}, {69.2, 29836.08020979021}, {69.4,
29898.33790209791}, {69.6, 29933.56769230769}, {69.8,
29959.04762237762}, {70, 29975.020909090912}, {70.2,
29991.388531468532}, {70.4, 30006.784055944052}, {70.6,
30018.964685314684}, {70.8, 30026.687132867133}, {71,
30047.393426573428}, {71.2, 30084.82174825175}, {71.4,
30135.9965034965}, {71.6, 30182.328111888113}, {71.8,
30225.142167832168}, {72, 30268.663566433566}, {72.2,
30319.640629370628}, {72.4, 30372.744545454545}, {72.6,
30427.39160839161}, {72.8, 30477.89188811188}, {73,
30521.84727272727}, {73.2, 30553.777762237765}, {73.4,
30573.294825174824}, {73.6, 30571.749790209793}, {73.8,
30562.458741258743}, {74, 30552.884825174824}, {74.2,
30553.355174825174}, {74.4, 30564.295454545452}, {74.6,
30576.382587412594}, {74.8, 30594.90377622378}, {75,
30610.827692307692}, {75.2, 30633.06699300699}, {75.4,
30653.350000000002}, {75.6, 30666.33594405594}, {75.8,
30668.923426573427}, {76, 30668.75461538462}, {76.2,
30670.575314685306}, {76.4, 30670.93328671329}, {76.6,
30667.266083916085}, {76.8, 30663.819300699302}, {77,
30647.977062937065}, {77.2, 30618.72202797203}, {77.4,
30565.47013986014}, {77.6, 30508.620349650355}, {77.8,
30455.27230769231}, {78, 30410.724055944054}, {78.2,
30383.247272727276}, {78.4, 30363.072377622375}, {78.6,
30355.305034965033}, {78.8, 30342.20923076923}, {79,
30340.65146853147}, {79.2, 30337.188811188807}, {79.4,
30331.158181818184}, {79.6, 30315.162097902103}, {79.8,
30295.13181818182}, {80, 30271.48195804196}, {80.2,
30250.13118881119}, {80.4, 30224.207062937065}, {80.6,
30201.98300699301}, {80.8, 30170.62013986014}, {81,
30157.62923076923}, {81.2, 30143.96188811189}, {81.4,
30141.00909090909}, {81.6, 30117.328741258738}, {81.8,
30092.859790209794}, {82, 30056.212097902095}, {82.2,
30011.19230769231}, {82.4, 29951.637552447555}, {82.6,
29881.86965034965}, {82.8, 29809.408811188812}, {83,
29743.92013986014}, {83.2, 29687.225244755246}, {83.4,
29650.274545454547}, {83.6, 29609.51027972028}, {83.8,
29570.36111888112}, {84, 29528.284685314688}, {84.2,
29495.74104895105}, {84.4, 29464.83104895105}, {84.6,
29432.034545454546}, {84.8, 29397.90867132867}, {85,
29359.92979020979}, {85.2, 29328.5486013986}, {85.4,
29309.78937062937}, {85.6, 29295.625034965036}, {85.8,
29279.513916083917}, {86, 29255.218671328672}, {86.2,
29234.38566433567}, {86.4, 29227.73384615385}, {86.6,
29216.327202797198}, {86.8, 29201.22685314685}, {87,
29162.052937062937}, {87.2, 29113.863776223774}, {87.4,
29051.34391608391}, {87.6, 28988.94237762238}, {87.8,
28926.36160839161}, {88, 28856.33132867133}, {88.2,
28782.890699300704}, {88.4, 28712.760769230772}, {88.6,
28660.5920979021}, {88.8, 28620.868461538463}, {89,
28583.4386013986}, {89.2, 28546.60818181818}, {89.4,
28502.005384615386}, {89.6, 28462.87916083916}, {89.8,
28422.843076923076}, {90, 28389.142517482516}, {90.2,
28339.938461538462}, {90.4, 28275.94958041958}, {90.6,
28203.151538461538}, {90.8, 28132.62300699301}, {91,
28069.04839160839}, {91.2, 27992.026083916087}, {91.4,
27914.222797202798}, {91.6, 27834.239160839163}, {91.8,
27766.07118881119}, {92, 27716.52062937063}, {92.2,
27679.7613986014}, {92.4, 27652.8013986014}, {92.6,
27618.464055944052}, {92.8, 27588.78923076923}, {93,
27574.388531468536}, {93.2, 27566.27888111888}, {93.4,
27547.25811188811}, {93.6, 27502.117692307693}, {93.8,
27444.676573426572}};
ramp1FSmoothFunc[1] = Interpolation[ramp1FCelsiusXRFUSmooth[1]]
ClearAll[helixMidPoint, helixLineLength, helixLowPoint, \
helixLowPointRFU, helixHighPoint, helixHighPointRFU]
ClearAll[coilMidPoint, coilLineLength, coilLowPoint, coilLowPointRFU, \
coilHighPoint, coilHighPointRFU]
ramp1FCelsiusXRFUSmooth[1];
helixLowBarrier = 10;
helixHighBarrier = 40;
coilLowBarrier = 60;
coilHighBarrier = 90;
{Slider[Dynamic[helixMidPoint], {helixLowBarrier, helixHighBarrier}],
Dynamic[helixMidPoint],
Dynamic[helixMidPointRFU = ramp1FSmoothFunc[1][helixMidPoint]],
Slider[Dynamic[helixLineLength], {5, 25}], Dynamic[helixLineLength]}
{Slider[Dynamic[coilMidPoint], {coilLowBarrier, coilHighBarrier}],
Dynamic[coilMidPoint],
Dynamic[coilMidPointRFU = ramp1FSmoothFunc[1][coilMidPoint]],
Slider[Dynamic[coilLineLength], {5, 25}], Dynamic[coilLineLength]}
Dynamic[{ListPlot[{ramp1FCelsiusXRFUSmooth[
1], {{helixLowPoint, helixLowPointRFU}}, {{helixHighPoint,
helixHighPointRFU}}, {{coilLowPoint,
coilLowPointRFU}}, {{coilHighPoint, coilHighPointRFU}}},
ImageSize -> Medium,
PlotStyle -> {PointSize[Small], PointSize[Large], PointSize[Large],
PointSize[Large], PointSize[Large]}],
Grid[{{, "temperature (C)", "Interpolated RFU"}, {"helix low point",
Dynamic[helixLowPoint = helixMidPoint - helixLineLength/2],
Dynamic[helixLowPointRFU =
ramp1FSmoothFunc[1][helixLowPoint]]}, {"helix high point",
Dynamic[helixHighPoint = helixMidPoint + helixLineLength/2],
Dynamic[helixHighPointRFU =
ramp1FSmoothFunc[1][
helixHighPoint]]}, {, ,}, {"coil low point",
Dynamic[coilLowPoint = coilMidPoint - coilLineLength/2],
Dynamic[coilLowPointRFU =
ramp1FSmoothFunc[1][coilLowPoint]]}, {"coil high point",
Dynamic[coilHighPoint = coilMidPoint + coilLineLength/2],
Dynamic[coilHighPointRFU = ramp1FSmoothFunc[1][coilHighPoint]]}},
Frame -> All]}]
Dynamic[ramp1FBaseLinesTEST =
Plot[{ramp1FHelixLinFitEqTEST[temp],
ramp1FCoilLinFitEqTEST[temp]}, {temp, 1, 100}]]
Dynamic[ramp1FHelixTEST =
Select[ramp1FCelsiusXRFUSmooth[1],
helixLowPoint <= #[[1]] <= helixHighPoint &]]
Dynamic[ramp1FHCoilTEST =
Select[ramp1FCelsiusXRFUSmooth[1],
coilLowPoint <= #[[1]] <= coilHighPoint &]]
Dynamic[ramp1FHelixLinFitTEST =
Fit[ramp1FHelixTEST, {1, temp}, temp]]
Dynamic[ramp1FHelixLinFitEqTEST[temp_] = ramp1FHelixLinFitTEST]
Dynamic[ramp1FCoilLinFitTEST = Fit[ramp1FHCoilTEST, {1, temp}, temp]]
Dynamic[ramp1FCoilLinFitEqTEST[temp_] = ramp1FCoilLinFitTEST]
Look at Manipulate, it should automate what you're trying to do with Dynamic. For example, Manipulate[Show[<plots>], {param, min, max}] should work.

PlotLegends` default options

I'm trying to redefine an option of the PlotLegends package after having loaded it,
but I get for example
Needs["PlotLegends`"]
SetOptions[ListPlot,LegendPosition->{0,0.5}]
=> SetOptions::optnf: LegendPosition is not a known option for ListPlot.
I expect such a thing as the options in the PlotLegends package aren't built-in to Plot and ListPlot.
Is there a way to redefine the default options of the PlotLegends package?
The problem is not really in the defaults for PlotLegends`. To see it, you should inspect the ListPlot implementation:
In[28]:= Needs["PlotLegends`"]
In[50]:= DownValues[ListPlot]
Out[50]=
{HoldPattern[ListPlot[PlotLegends`Private`a:PatternSequence[___,
Except[_?OptionQ]]|PatternSequence[],PlotLegends`Private`opts__?OptionQ]]:>
PlotLegends`Private`legendListPlot[ListPlot,PlotLegends`Private`a,
PlotLegend/.Flatten[{PlotLegends`Private`opts}],PlotLegends`Private`opts]
/;!FreeQ[Flatten[{PlotLegends`Private`opts}],PlotLegend]}
What you see from here is that options must be passed explicitly for it to work, and moreover, PlotLegend option must be present.
One way to achieve what you want is to use my option configuration manager, which imitates global options by passing local ones. Here is a version where option-filtering is made optional:
ClearAll[setOptionConfiguration, getOptionConfiguration, withOptionConfiguration];
SetAttributes[withOptionConfiguration, HoldFirst];
Module[{optionConfiguration}, optionConfiguration[_][_] = {};
setOptionConfiguration[f_, tag_, {opts___?OptionQ}, filterQ : (True | False) : True] :=
optionConfiguration[f][tag] =
If[filterQ, FilterRules[{opts}, Options[f]], {opts}];
getOptionConfiguration[f_, tag_] := optionConfiguration[f][tag];
withOptionConfiguration[f_[args___], tag_] :=
f[args, Sequence ## optionConfiguration[f][tag]];
];
To use this, first define your configuration and a short-cut macro, as follows:
setOptionConfiguration[ListPlot,"myConfig", {LegendPosition -> {0.8, -0.8}}, False];
withMyConfig = Function[code, withOptionConfiguration[code, "myConfig"], HoldAll];
Now, here you go:
withMyConfig[
ListPlot[{#, Sin[#]} & /# Range[0, 2 Pi, 0.1], PlotLegend -> {"sine"}]
]
LegendsPosition works in ListPlot without problems (for me at least). You don't happen to have forgotten to load the package by using Needs["PlotLegends"]`?
#Leonid, I added the possibility to setOptionConfiguration to set default options to f without having to use a short-cut macro.
I use the trick exposed by Alexey Popkov in What is in your Mathematica tool bag?
Example:
Needs["PlotLegends`"];
setOptionConfiguration[ListPlot, "myConfig", {LegendPosition -> {0.8, -0.8}},SetAsDefault -> True]
ListPlot[{#, Sin[#]} & /# Range[0, 2 Pi, 0.1], PlotLegend -> {"sine"}]
Here is the implementation
Options[setOptionConfiguration] = {FilterQ -> False, SetAsDefault -> False};
setOptionConfiguration[f_, tag_, {opts___?OptionQ}, OptionsPattern[]] :=
Module[{protectedFunction},
optionConfiguration[f][tag] =
If[OptionValue#FilterQ, FilterRules[{opts},
Options[f]]
,
{opts}
];
If[OptionValue#SetAsDefault,
If[(protectedFunction = MemberQ[Attributes[f], Protected]),
Unprotect[f];
];
DownValues[f] =
Union[
{
(*I want this new rule to be the first in the DownValues of f*)
HoldPattern[f[args___]] :>
Block[{$inF = True},
withOptionConfiguration[f[args], tag]
] /; ! TrueQ[$inF]
}
,
DownValues[f]
];
If[protectedFunction,
Protect[f];
];
];
];

Parallelize behavior

I'm trying to understand some quirks of the Parallelize[] behavior.
If I do:
CloseKernels[];
LaunchKernels[1]
f[n_, g_] :=
First#AbsoluteTiming[
g[Product[Mod[i, 2], {i, 1, n/2}]
Product[Mod[i, 2], {i, n/2 + 1, n}]]];
Clear[a, b];
a = Table[f[i, Identity], {i, 100000, 1500000, 100000}];
LaunchKernels[1]
b = Table[f[i, Parallelize], {i, 100000, 1500000, 100000}];
ListLinePlot[{a, b}, PlotStyle -> {Red, Blue}]
The result is the expected one:
CPU utilization:
But if I do the same, changing the function to evaluate:
CloseKernels[];
LaunchKernels[1]
f[n_, g_] :=
First#AbsoluteTiming[
g[Product[Sin#i, {i, 1, n/2}]
Product[Sin#i, {i, n/2 + 1, n}]]];
Clear[a, b];
a = Table[f[i, Identity], {i, 1000, 15000, 1000}];
LaunchKernels[1]
b = Table[f[i, Parallelize], {i, 1000, 15000, 1000}];
ListLinePlot[{a, b}, PlotStyle -> {Red, Blue}]
The result is:
CPU utilization:
I think I am missing some important knowledge about Parallelize[] to understand this.
Any hints?
My guess is that the problem is not in Parallelize, but in what you are trying to compute. For Mod, the result is always either 1 or 0 and the product as well. For Sin, since you use the integer arithmetic, you accumulate huge symbolic expressions (products of Sin[i]). They are discarded after having been computed, but they need the heap space (memory allocation/deallocation). The quadratic behavior you observe is likely due to the linear complexity of large size memory allocation, "multiplied" by the liner complexity from your iteration. This seems the dominant effect, which shadows the real costs of Parallelize. If you apply N, like Sin#N[i], the results are quite different.
To understand what is going on behind the scenes when using Parallelize, it's a good idea to enable the Parallel Computing Toolkit's debugging mode, i.e.:
Needs["Parallel`Debug`"]
SetOptions[$Parallel, Tracers -> {SendReceive}]
The second example produces a lot of MathLink communication overhead, because the Sin function applied to an integer number is not immediately evaluated by Mathematica (as Leonid Shifrin already mentioned):
Here's a portion of the debugging output:
SendReceive: Receiving from kernel 13: Subscript[iid, 105][Sin[1] Sin[2] Sin[3] Sin[4] Sin[5] Sin[6] Sin[7] Sin[8] Sin[9] Sin[10] Sin[11] Sin[12] Sin[13] Sin[14] Sin[15] Sin[16] Sin[17] Sin[18] Sin[19] Sin[20] Sin[21] Sin[22] Sin[23] Sin[24] Sin[25] Sin[26] Sin[27] Sin[28] Sin[29] Sin[30] Sin[31] Sin[32] Sin[33] Sin[34] Sin[35] Sin[36] Sin[37] Sin[38] Sin[39] Sin[40] Sin[41] Sin[42] Sin[43] Sin[44] Sin[45] Sin[46] Sin[47] Sin[48] Sin[49] Sin[50] Sin[51] Sin[52] Sin[53] Sin[54] Sin[55] Sin[56] Sin[57] Sin[58] Sin[59] Sin[60] Sin[61] Sin[62] Sin[63] Sin[64] Sin[65] Sin[66] Sin[67] Sin[68] Sin[69] Sin[70] Sin[71] Sin[72] Sin[73] Sin[74] Sin[75] Sin[76] Sin[77] Sin[78] Sin[79] Sin[80] Sin[81] Sin[82] Sin[83] Sin[84] Sin[85] Sin[86] Sin[87] Sin[88] Sin[89] Sin[90] Sin[91] Sin[92] Sin[93] Sin[94] Sin[95] Sin[96] Sin[97] Sin[98] Sin[99] Sin[100] Sin[101] Sin[102] Sin[103] Sin[104] Sin[105] Sin[106] Sin[107] Sin[108] Sin[109] Sin[110] Sin[111] Sin[112] Sin[113] Sin[114] Sin[115] Sin[116] Sin[117] Sin[118] Sin[119] Sin[120] Sin[121] Sin[122] Sin[123] Sin[124] Sin[125] Sin[126] Sin[127] Sin[128] Sin[129] Sin[130] Sin[131] Sin[132] Sin[133] Sin[134] Sin[135] Sin[136] Sin[137] Sin[138] Sin[139] Sin[140] Sin[141] Sin[142] Sin[143] Sin[144] Sin[145] Sin[146] Sin[147] Sin[148] Sin[149] Sin[150] Sin[151] Sin[152] Sin[153] Sin[154] Sin[155] Sin[156] Sin[157] Sin[158] Sin[159] Sin[160] Sin[161] Sin[162] Sin[163] Sin[164] Sin[165] Sin[166] Sin[167] Sin[168] Sin[169] Sin[170] Sin[171] Sin[172] Sin[173] Sin[174] Sin[175] Sin[176] Sin[177] Sin[178] Sin[179] Sin[180] Sin[181] Sin[182] Sin[183] Sin[184] Sin[185] Sin[186] Sin[187] Sin[188] Sin[189] Sin[190] Sin[191] Sin[192] Sin[193] Sin[194] Sin[195] Sin[196] Sin[197] Sin[198] Sin[199] Sin[200] Sin[201] Sin[202] Sin[203] Sin[204] Sin[205] Sin[206] Sin[207] Sin[208] Sin[209] Sin[210] Sin[211] Sin[212] Sin[213] Sin[214] Sin[215] Sin[216] Sin[217] Sin[218] Sin[219] Sin[220] Sin[221] Sin[222] Sin[223] Sin[224] Sin[225] Sin[226] Sin[227] Sin[228] Sin[229] Sin[230] Sin[231] Sin[232] Sin[233] Sin[234] Sin[235] Sin[236] Sin[237] Sin[238] Sin[239] Sin[240] Sin[241] Sin[242] Sin[243] Sin[244] Sin[245] Sin[246] Sin[247] Sin[248] Sin[249] Sin[250] Sin[251] Sin[252] Sin[253] Sin[254] Sin[255] Sin[256] Sin[257] Sin[258] Sin[259] Sin[260] Sin[261] Sin[262] Sin[263] Sin[264] Sin[265] Sin[266] Sin[267] Sin[268] Sin[269] Sin[270] Sin[271] Sin[272] Sin[273] Sin[274] Sin[275] Sin[276] Sin[277] Sin[278] Sin[279] Sin[280] Sin[281] Sin[282] Sin[283] Sin[284] Sin[285] Sin[286] Sin[287] Sin[288] Sin[289] Sin[290] Sin[291] Sin[292] Sin[293] Sin[294] Sin[295] Sin[296] Sin[297] Sin[298] Sin[299] Sin[300] Sin[301] Sin[302] Sin[303] Sin[304] Sin[305] Sin[306] Sin[307] Sin[308] Sin[309] Sin[310] Sin[311] Sin[312] Sin[313] Sin[314] Sin[315] Sin[316] Sin[317] Sin[318] Sin[319] Sin[320] Sin[321] Sin[322] Sin[323] Sin[324] Sin[325] Sin[326] Sin[327] Sin[328] Sin[329] Sin[330] Sin[331] Sin[332] Sin[333] Sin[334] Sin[335] Sin[336] Sin[337] Sin[338] Sin[339] Sin[340] Sin[341] Sin[342] Sin[343] Sin[344] Sin[345] Sin[346] Sin[347] Sin[348] Sin[349] Sin[350] Sin[351] Sin[352] Sin[353] Sin[354] Sin[355] Sin[356] Sin[357] Sin[358] Sin[359] Sin[360] Sin[361] Sin[362] Sin[363] Sin[364] Sin[365] Sin[366] Sin[367] Sin[368] Sin[369] Sin[370] Sin[371] Sin[372] Sin[373] Sin[374] Sin[375] Sin[376] Sin[377] Sin[378] Sin[379] Sin[380] Sin[381] Sin[382] Sin[383] Sin[384] Sin[385] Sin[386] Sin[387] Sin[388] Sin[389] Sin[390] Sin[391] Sin[392] Sin[393] Sin[394] Sin[395] Sin[396] Sin[397] Sin[398] Sin[399] Sin[400] Sin[401] Sin[402] Sin[403] Sin[404] Sin[405] Sin[406] Sin[407] Sin[408] Sin[409] Sin[410] Sin[411] Sin[412] Sin[413] Sin[414] Sin[415] Sin[416] Sin[417] Sin[418] Sin[419] Sin[420] Sin[421] Sin[422] Sin[423] Sin[424] Sin[425] Sin[426] Sin[427] Sin[428] Sin[429] Sin[430] Sin[431] Sin[432] Sin[433] Sin[434] Sin[435] Sin[436] Sin[437] Sin[438] Sin[439] Sin[440] Sin[441] Sin[442] Sin[443] Sin[444] Sin[445] Sin[446] Sin[447] Sin[448] Sin[449] Sin[450] Sin[451] Sin[452] Sin[453] Sin[454] Sin[455] Sin[456] Sin[457] Sin[458] Sin[459] Sin[460] Sin[461] Sin[462] Sin[463] Sin[464] Sin[465] Sin[466] Sin[467] Sin[468] Sin[469] Sin[470] Sin[471] Sin[472] Sin[473] Sin[474] Sin[475] Sin[476] Sin[477] Sin[478] Sin[479] Sin[480] Sin[481] Sin[482] Sin[483] Sin[484] Sin[485] Sin[486] Sin[487] Sin[488] Sin[489] Sin[490] Sin[491] Sin[492] Sin[493] Sin[494] Sin[495] Sin[496] Sin[497] Sin[498] Sin[499] Sin[500]] (q=0)
Try this version and I'm sure you will know what's going on.
CloseKernels[];
LaunchKernels[1]
f[n_, g_] :=
First#AbsoluteTiming[
g[Product[Sin#i, {i, 1, n/2}] Product[Sin#i, {i, n/2 + 1, n}]]];
Clear[a, b];
a = Table[f[i, Identity], {i, 1000, 15000, 1000}];
LaunchKernels[1]
b1 = Table[f[i, Parallelize], {i, 1000, 15000, 1000}];
b2 = Table[f[i, Parallelize], {i, 1000., 15000., 1000.}];
ListLinePlot[{a, b1, b2}, PlotStyle -> {Red, Blue, Green}]

Resources