2
$\begingroup$

I am trying to draw some curves with colors oscillating between red and blue (as a function of arc length along the curve). To make things easier, I am using circle arcs so that the curves are easily parameterized by arc length. I want to compare multiple curves of the same family, and the family parameter is a, which is the distance from the x-axis to the center of the circle (which is at the point (0,-a)). I am only plotting the portion of the circle which lies above the x-axis.

Anyway, here is my code:

g[a_,t_]:={Sqrt[a^2+1]Cos[t],Sqrt[a^2+1]Sin[t]-a};

cf[a_,t_]:=Blend[{Blue,Red},(Sin[100t Sqrt[a^2+1] ]+1)/2];

curve[a_]:=ParametricPlot[
    g[a,t],
    {t,ArcCos[1/Sqrt[a^2+1]],Pi-ArcCos[1/Sqrt[a^2+1]]},
    ColorFunction->Function[{x,y,t},cf[a,t]],
    PlotStyle->Thickness[0.01],
    ColorFunctionScaling->True,
    ImageSize->1200,
    Axes->False
];

Show[curve[1],curve[2],curve[3]]

And here is my output: enter image description here

As you can see, the oscillating works OK for some values of a, but it looks terrible for others. I have tried some other curves as well, and there always seems to be some issue. Before, I thought it was because I wasn't parameterizing the curve by arc length, so Mathematica was sampling the points in the domain for the color function at strange times. But now these curves are parameterized by arc length, and so I have no idea what's going on.

By the way, I am using Wolfram Cloud for this. Any advice would be appreciated, thank you!

Edit: Here is the output with ColorFunctionScaling->False: enter image description here

$\endgroup$
2
  • $\begingroup$ Use ColorFunctionScaling -> False $\endgroup$
    – Bob Hanlon
    Jan 17 at 20:53
  • $\begingroup$ I just updated the question with this option; it still looks bad but in a different way... $\endgroup$ Jan 17 at 21:19

1 Answer 1

2
$\begingroup$

I figured out a solution: I needed to set the Mesh option to be higher. In this case, Mesh->100 worked fine.

$\endgroup$
3
  • $\begingroup$ Ok, now I have a new problem; the mesh points are appearing in my images and I don't know how to get rid of them... but I guess this is a separate issue. $\endgroup$ Jan 17 at 22:18
  • $\begingroup$ After reading the documentation, it seems like Mesh is an option that is used for showing the mesh, rather than setting the mesh size. But I've got no idea how to set the mesh size properly now... $\endgroup$ Jan 17 at 22:28
  • $\begingroup$ After doing even more experimenting, it seems like whether or not setting Mesh->100 actually shows the mesh or not is up to random chance. I've run the same code twice and gotten different results. I'm willing to conclude at this point that this is a bug, unless someone wants to correct me. $\endgroup$ Jan 17 at 22:34

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.