I have one function and some data that I want to plot together.

I have two questions.

  1. How can I have a legend for dataMC list plot?
  2. How can I rotate the CMontkhab2 function plot a little to get it closer to the green points?

This is my code

  Plot[CMontkhab2, {r, 0.2, 1.1}, 
    PlotLegends -> {"\!\(\*SubscriptBox[\(C\), \(PFC + RELK\)]\)(r)"}, 
    PlotStyle -> {Thickness[0.006]}], 
     PlotStyle -> {{Green, PointSize[0.02]}}]}, 
  LabelStyle -> {Bold, Gray, 20}, ImageSize -> Scaled[0.7], 
  Frame -> True, FrameLabel -> {"r", "C(r)"}, LabelStyle -> Bold]

and this is my plot

enter image description here

Here is the CMontkhab2 function I want to rotate a bit, so it gets closer to the green points:

  8 + 0.15 E^(-4.94941 r^2) (-104.167 + 219.33 r - 684.841 r^3) + 
  0.15 (-59.2126 + 68.9522 r - 14.5717 r^3) + 
  0.7 (-59.5597 + 60.1605 r - 12.6466 r^3)

closed as unclear what you're asking by corey979, MarcoB, J. M. will be back soon Sep 12 '17 at 16:28

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.

  • $\begingroup$ 1-How can i data plot put the label could you rephrase this? It is not clear what you are asking. 2-How can I rotate the function plot to match the green points? Is the function you have an expression? But If you want the function to match exactly the points, then why not just plot the points? Also, without showing the data or code for the function, it will make it hard to answer this fully. $\endgroup$ – Nasser Sep 11 '17 at 11:29
  • $\begingroup$ 1-I want to put a legend for data plot @nasser $\endgroup$ – asal Sep 11 '17 at 11:32
  • $\begingroup$ Can you fit a function to dataMC and plot that instead? $\endgroup$ – aardvark2012 Sep 11 '17 at 11:33
  • $\begingroup$ For question 1 maybe this could help. $\endgroup$ – aardvark2012 Sep 11 '17 at 11:35
  • $\begingroup$ In fact these green points is correct criterion and i should can Match the blue line on it.That's why I need to rotate blue line. and my function(Blue line function) have an expression.@nasser $\endgroup$ – asal Sep 11 '17 at 11:42

To answer your question about adding a legend to the data list plot, try adding the option PlotLegends -> {"Data"} to that plot.

Here the code.

Your function

f[r_] :=
  8 + 0.15 E^(-4.94941 r^2) (-104.167 + 219.33 r - 684.841 r^3) + 
  0.15 (-59.2126 + 68.9522 r - 14.5717 r^3) + 
  0.7 (-59.5597 + 60.1605 r - 12.6466 r^3)

Some contrived data since you didn't give us a list of your data points.

data[u_, x0_] :=
  Table[RotationTransform[u Degree, {x0, f[x0]}][{x, f[x]}], {x, .2, 1., .05}]
pts = data[-.25, .6];

The plot with legends for both curve and data points

  Plot[f[r], {r, 0.2, 1.1}, 
    PlotLegends -> {"\!\(\*SubscriptBox[\(C\), \(PFC + RELK\)]\)(r)"}, 
    PlotStyle -> {Thickness[0.006]}],
    PlotLegends -> {"Data"},
    PlotStyle -> {{Green, PointSize[0.02]}}],
  LabelStyle -> {Bold, Gray, 12},
  ImageSize -> Scaled[.8],
  Frame -> True,
  FrameLabel -> {"r", "C(r)"}]


Note: I made the contrived data by rotating your function about a certain point on it. Is that not ironic?


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