0
$\begingroup$

I have a parametric funtion say, (f(t) cos t, f(t) sin t) and another function g(t). Now I want to plot (f(t) cos t, f(t) sin t) and show g(t) in bar legend for same range of t. for example t=0.5 corresponds to same color in g(t) bar and the plot. Is there any way to do it?

Here is a simple example code,

f[t_] := t + 1
g[t_] := t^3 + 3*t + 12
ParametricPlot[{f[t]*Cos[\[Theta]], f[t]*Sin[\[Theta]]}, {t, 0, 1}, {\[Theta], 0, 2*Pi}, ColorFunction -> Function[{x, y, t}, ColorData["SolarColors"][Rescale[g[t], {g[0], g[1]}, {0, 1}]]]

This give the following figure, enter image description here

The figure is ok, but i want to show g[t] in bar legend for the same range of t. Is there any way?

$\endgroup$
5
  • $\begingroup$ Yes, there is. Look at ParametricPlot and the corresponding option ColorFunction. Try it yourself, then edit the question and include the code if you encounter any problems. $\endgroup$
    – Domen
    Commented May 1 at 8:14
  • $\begingroup$ @Domen First of all I would like to express my gratitude and thanks for all your response and efforts you have shown. Yes, I am trying but cannot join two different function with same color scheme. I will try and update the code later on. Thank you very much again. $\endgroup$ Commented May 1 at 8:35
  • $\begingroup$ One way to join the functions would be using Show function as follows: Show[{ParametricPlot[body], Plot[g[t],{t,t1,t2},PlotStyle->White, PlotLegends...]}] In this case, the plot of the function g(t) will not be visible, but its legend will still appear. Hope I understood your problem correctly, and it helps. $\endgroup$ Commented May 1 at 11:29
  • $\begingroup$ @Domen Thank you for your response... I have updated my question in simplest way possible. $\endgroup$ Commented May 2 at 7:18
  • $\begingroup$ @AlexeiBoulbitch Here is updated question with simple code. $\endgroup$ Commented May 2 at 7:19

1 Answer 1

0
$\begingroup$

Thank You everyone from the mathematica stackexchange community and special thanks to people who responded to my question. I actually got the answer and I am posting the code here if someone needs in future.

I have used the code ParametricPlot[{f[t]*Cos[\[Theta]], f[t]*Sin[\[Theta]]}, {t, 0, 1}, {\[Theta], 0, 2*Pi}, ColorFunction -> Function[{x, y, t}, ColorData["SolarColors"][Rescale[g[t], {g[0], g[1]}]]], PlotLegends -> BarLegend[{"SolarColors", {g[0], g[1]}}, LegendLabel -> Style[HoldForm[g], 14]]

This gives the desired result-

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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