I am currently fighting with certain LogLinearPlot shenanigans.

LogLinearPlot issues

You can see:

  1. Term reordering in the PlotLegends.
  2. No colors for the plot legends (the graphs themselves have them)
  3. Weird 'cutoff' in the graph for one of the functions
  4. An error

    "An unknown box name (Superscript) was sent as the BoxForm for the expression. Check the format rules for the expression."

in the messages window for {N, 1, 10000} as parameter range. (The error vanishes for {N, 1, 1000}, but it doesn't seem to affect the other issues)

Can someone give me some hints as to what is going on, how to figure out the weird error 4, and how to fix the other things as well? Using Plot instead of LogLinearPlot does not exhibit any of these issues.


closed as off-topic by Jason B., m_goldberg, WReach, user9660, bbgodfrey Jan 24 '16 at 12:48

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." – Jason B., m_goldberg, WReach, Community, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ In future, please display copy-pastable code rather than a screenshot. Your problem is that N is a Mathematica command, so use lower case, i.e., LogLinearPlot[{n^3/6 - n/6, n}, {n, 1, 10000}] $\endgroup$ – bill s Jan 23 '16 at 15:23
  • $\begingroup$ That seems to have been the issue ... well, at least partially. Issues 2-4 seem to go away with your suggestion, however, term reordering (1) is still occurring ... $\endgroup$ – MrCC Jan 23 '16 at 15:42
  • 1
    $\begingroup$ What you call "term reordering" has nothing to do with plot legends or plot. Just evaluate n^3/6 - n/6 and it will place the terms as it finds convenient. Use HoldForm[n^3/6 - n/6] if you must have them in that order. $\endgroup$ – bill s Jan 23 '16 at 16:04
  • $\begingroup$ As a matter of fact, it actually has. If you use Plot instead of LogLinearPlot and swap around the terms in your formula, you'll instantly see that Plot respects the term order in the legends, whereas LogLinearPlot doesn't. HoldForm doesn't seem to be of help in this case, neither: Neither Plot nor LogLinearPlot evaluate expressions from within such a 'held' expression. Anyway, thanks for your help. $\endgroup$ – MrCC Jan 23 '16 at 16:50

There are two issues here:

Issue 1: Use of capital N

This is a common problem -- don't use N or any other built-in symbol as the name of a variable. I changed it to x (you have f(x) in there somewhere, so I figured I'd keep that x) and got a perfectly normal plot from:

 {x^3/6 - x/6, x^3}, {x, 1, 10^5},
 PlotLegends -> "Expressions", AxesLabel -> {"x", "f(x)"}

Issue 2: Plot Labels

This issue appears to be present only in older versions of Mathematica. I'm on 10.2 and the plot legends come out as you desire by default. I believe that would qualify as either a "bug" or "missing feature" (depending on how you look at it) that has been corrected. (Based on the colors in your screen-shot, I assume you're using an older version.)

  • $\begingroup$ Yea, as bill-s pointed out in one of the comments, the problems (2)-(4) came from using N as the parameter name. Interestingly, Plot doesn't exhibit this behaviour and correctly treats N as parameter. Even the syntax parser seems to be aware of the difference in context (via coloring in the editor). The last remaining issue is clearly a bug (I'm on Mathematica 9): For all i care LogLinearPlot could be using 1/6 (-x + x^2) (1 + x) as internal representation for evaluation, however when PlotLegends are to be the input "Expressions", I expect the original input expression to show up. $\endgroup$ – MrCC Jan 26 '16 at 14:38
  • $\begingroup$ It probably has to do with how LogLinearPlot handles its input. It may have to be a bit more careful about having huge values in the logarithmic variable. I can only imagine LogLinearPlot does something, then passes that something to Plot -- the pre-processing before that hand-off is where it fudges some of the parameters on the way through. $\endgroup$ – Kellen Myers Jan 27 '16 at 5:07

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