2
$\begingroup$

I have been trying to use Plot with a nested map to make plots of a numerically integrated function with different argument parameters, and after some searching I have finally got that sorted. My MWE looks like this:

colors = (("DefaultPlotStyle" /. (Method /. 
    Charting`ResolvePlotTheme["Default", ListLinePlot])) /. 
Directive[x_, __] :> x);
f[x_, y_] := y Sin[y Log[x]]
Plot[Map[f[l, #]/l &, {0.05, 0.1, 0.2}], {l, 0, 100}, Evaluated -> True,
 PlotStyle -> colors, Frame -> True, 
 FrameLabel -> {"x", "f", "f=y Sin(y ln(x))"}, 
 PlotLegends -> LineLegend[colors, {"y=0.05", "y=0.1", "y=0.02"}]]

example

Which works beautifully, but now I want to plot something in the same way but with a logarithmically scaled x-axis. LogLinearPlot obviously does this but doesn't accept an "Evaluated" argument, and I can't figure out how to get the lines to all have a different color.

Is there a method which does this and is portable across all incarnations of *Plot function?

$\endgroup$

closed as off-topic by MarcoB, dr.blochwave, C. E., m_goldberg, Bob Hanlon Sep 4 '15 at 4:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, dr.blochwave, C. E., m_goldberg, Bob Hanlon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Wrap the first argument of your plot in Evaluate, i.e. Evaluate[Map[...]], or equivalently Evaluate@Map[...]. You will also want to change the range for the l variable so it doesn't include $0$ for a logarithmic plot. $\endgroup$ – MarcoB Sep 3 '15 at 16:01
  • $\begingroup$ Nope... That breaks things completely and I get an empty graph $\endgroup$ – PTooley Sep 3 '15 at 16:25
  • $\begingroup$ LogLinearPlot[#, <options>] & @ Map[f[l, #]/l &, {0.05, 0.1, 0.2}] $\endgroup$ – march Sep 3 '15 at 16:31
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$ – bbgodfrey Sep 3 '15 at 16:39
  • $\begingroup$ @telemin Did you remove the Evaluated option though? I posted what I see below as an answer, with the addition of Evaluate and the change in plotting domain to accommodate the logarithmic axes. $\endgroup$ – MarcoB Sep 3 '15 at 17:03
3
$\begingroup$
colors = 
  (("DefaultPlotStyle" /. 
     (Method /. Charting`ResolvePlotTheme["Default", ListLinePlot])) /. 
        Directive[x_, __] :> x);
f[x_, y_] := y Sin[y Log[x]]

LogLinearPlot[
  Evaluate @ Map[f[l, #]/l &, {0.05, 0.1, 0.2}], {l, 1, 100}, 
    (*notice the removal of zero, which won't work in LogPlot*)
  PlotStyle -> colors, Frame -> True, 
  FrameLabel -> {"x", "f", "f=y Sin(y ln(x))"}, 
  PlotLegends -> LineLegend[colors, {"y=0.05", "y=0.1", "y=0.02"}]
]

Mathematica graphics

$\endgroup$

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