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$
  • $\begingroup$ Works with PlotRange -> {Automatic, {0, Automatic}} $\endgroup$ – Öskå May 6 '14 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 May 6 '14 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 May 6 '14 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 May 6 '14 at 22:12
  • 1
    $\begingroup$ @Öskå: Interesting. I'll try to pass this along to WRI Support, as suggested by Rasher. $\endgroup$ – Bezewy May 6 '14 at 23:34
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, privacy policy and cookie policy

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