0
$\begingroup$

I have some lists that will always contain non-negative values, sometimes all zeros. Whatever non-negative values appear in the list, I would like the plots to appear without a negative y-axis. I'll use constant arrays instead of real data for the purpose of this message:

ListLinePlot[ConstantArray[0, 640], PlotRange -> {Full, {0, Full}}]

zero case

ListLinePlot[ConstantArray[1, 640], PlotRange -> {Full, {0, Full}}]

one case

Ignore the aspect ratios... Doesn't the {0, Full} portion of PlotRange -> {Full, {0, Full}}] specify that I don't want to see anything under y == 0? If so, why does the first plot (zeros) produce a negative y-axis and is there any way to suppress it?

$\endgroup$
9
  • $\begingroup$ Works with PlotRange -> {Automatic, {0, Automatic}} $\endgroup$
    – Öskå
    Commented May 6, 2014 at 21:42
  • $\begingroup$ I get the same result when Full is replaced with Automatic (I'm running 9.0.1.0 if that matters). Besides, I really want the behavior of Full and not Automatic. $\endgroup$
    – Bezewy
    Commented May 6, 2014 at 21:53
  • $\begingroup$ @Bezewy: Probably one of those corner cases where MM's "try and make it pretty" heuristics fail, and you'll need to force it with something like PlotRange->{Full,{0,Max@data}}. FWIW, I see same behavior as you, 9.0.1 on windows, including same using Oska's suggestion. Might be a regression if Oska's on an earlier version, perhaps worth ping to WRI support. $\endgroup$
    – ciao
    Commented May 6, 2014 at 21:56
  • 1
    $\begingroup$ @Bezewy:Yep, just noticed that. So you'd need to provide some "minimum maximum" so to speak, like `PlotRange -> {Full, {0, Max[1, Max@data]}} $\endgroup$
    – ciao
    Commented May 6, 2014 at 22:12
  • 1
    $\begingroup$ @Öskå: Interesting. I'll try to pass this along to WRI Support, as suggested by Rasher. $\endgroup$
    – Bezewy
    Commented May 6, 2014 at 23:34

1 Answer 1

2
$\begingroup$

This appears to be one of those cases where the heuristics of "make it pretty" seems to fail (partially). If you want some set "floor" in this case, a construct like

ListLinePlot[data, PlotRange -> {Full, {0, Max[1, Max@data]}}]

should do the job.

$\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.