1
$\begingroup$

enter image description hereIn a simpler first case I plotted reasonably spaced (stability) contours by selecting a sequence of k values,

k = {.0001, .025, .055, .1, .15, .2, .25, .3, .35, .4, .5, .6, .7, .8, 1., 1.4, 1.8, 2.2, 2.6, 3, 4, 6, 8, 16}

and computing an analytic function at those k with a color sequence matched.

Now in a more complicated case to compare with the original at the same k values and colors, the analytic function is replaced by numerical integration and asymptotic expansion.

I generated a table of the new function at those k values, but ListLinePlot of these entries vs k draws disjointed line segments between the table points. I just want a smooth curve with no kinks. I tried ListCurvePathPlot and Interpolation Order but they still left the kinks at the admittedly coarse last few data points. I can create a second display list with more data points to minimise the kinks, but use the original for my stability curves for comparison with my earlier case.

Would be very grateful for any suggestions of other simple things I can try at the plot stage as I have now been stuck for several hours on this simple problem. Thank you

$\endgroup$

closed as unclear what you're asking by m_goldberg, MarcoB, Alex Trounev, José Antonio Díaz Navas, bbgodfrey Mar 29 at 0:59

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ Please post the code you've written so far. May be helpful to understand what you are doing ... $\endgroup$ – mjw Mar 25 at 4:09
  • 1
    $\begingroup$ Also, clarify what you need exactly!!? Plotting Smooth curve as i got! Right!? $\endgroup$ – Alrubaie Mar 25 at 14:16
  • $\begingroup$ u/sdb2754 was trying to write a function that plots a cubic fit to a data set (similar to ListLinePlot, but with splines instead of lines). He had:ListSplinePlot[data_, x_] := Show[ListPlot[data], Plot[InterpolatingPolynomial[data, x], {x, Min[Transpose[data][[1]]], Max[Transpose[data][[1]]]}], PlotRange -> All, AxesOrigin -> {0, 0}] That doesn't work, I have lists of 2 element lists with the first element k, no implicit x. I don't see where he specified that the polynomial is a cubic. Above all I don't understand why Mathematica does not have a built in ListSplinePlot $\endgroup$ – simon Mar 25 at 14:23
  • $\begingroup$ @simon Are you looking for something like ListLinePlot[k, InterpolationOrder -> 3]? $\endgroup$ – MarcoB Mar 25 at 14:32
  • 1
    $\begingroup$ Do you have a sense of the error size of your numerical integration? Also, an underlying structure/parameterization of the curves you are trying to pass through the points? $\endgroup$ – MikeY Mar 25 at 15:49
0
$\begingroup$

For your k table is the same

k = {.0001, .025, .055, .1, .15, .2, .25, .3, .35, .4, .5, .6, .7, .8,
    1., 1.4, 1.8, 2.2, 2.6, 3, 4, 6, 8, 16};

this is the curve using ListLinePlot or Joined in ListPlot

ListPlot[k, Joined -> True]

enter image description here

but you want it smooth curve!!? Here is

First Method

As well you can change n in FitPolynomial or x in Plot to get more desired result.

this it the best smooth curve i get!

k = {0.0001, 0.025, 0.055, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.5, 0.6, 0.7, 0.8, 
1., 1.4, 1.8, 2.2, 2.6, 3, 4, 6, 8, 16};

FitPolynomial[data_] := Fit[data, Table[x^n, {n, 0, 10}], x]; 
q = FitPolynomial[k]; 
p2 = Plot[q, {x, 1, 25}]

p1 = ListPlot[k]
Show[p1, p2]

enter image description here

Second Method

As well you can change order in InterpolationOrder

k = {.0001, .025, .055, .1, .15, .2, .25, .3, .35, .4, .5, .6, .7, .8,
1., 1.4, 1.8, 2.2, 2.6, 3, 4, 6, 8, 16};


p1 = ListPlot[k]
p2 = ListPlot[k, InterpolationOrder -> 5, PlotRange -> All, 
  Joined -> True]

Show[p1, p2]

enter image description here

$\endgroup$
  • $\begingroup$ I am so sorry you misunderstood the problem, There is no implicit x, the k's are my preselected x values. I have lists of {k,f1}, {k,f2} values etc and need each list of points to be spline plotted. I will study your answer to see if there is something there I can use $\endgroup$ – simon Mar 25 at 15:24

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