Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Logscale quality of life improvements #3921

Open
isentropic opened this issue Nov 3, 2021 · 1 comment
Open

[FR] Logscale quality of life improvements #3921

isentropic opened this issue Nov 3, 2021 · 1 comment
Labels
awesome log scales discussion enhancement improving existing functionality

Comments

@isentropic
Copy link
Member

Although Plots jl handles missing data and whatnot quite well in linear scales, passing negative values in log scales should behave similarly. Quite often I'm annoyed that zero number isn't displayed on a log scale. What I mean is that 0 in log scales should be displayed like lines into infinity:
Like this (there is a point in negative space but it is just interpreted as a line in MPL):

image

Quite often I'd like to plot results of FFT in frequency logscale, and it annoys me that I get this zero number warning. It annoys me that I have to just use MPL for this.

This should be addressed somewhere in the processing pipeline. Perhaps x<=0 values should be swapped out with missing early in the pipeline for the log scales.

As Plots follows "plot what you mean" philosophy, this should be a good long term change

@isentropic isentropic added discussion enhancement improving existing functionality labels Nov 3, 2021
@mcabbott
Copy link

mcabbott commented Dec 5, 2021

Plots should already skip zero / negative entries, just as it skips Inf / NaN. What it won't do at present is calculate the limits based only on the finite points, but you can provide them. For example:

plot(cumsum(randn(1000,4), dims=1), yaxis=(:log10, [0.1, :auto]))

cumsum

displayed like lines into infinity

Note that this isn't what Plots does for Inf in linear scale, it just omits the points.

plot(inv.(-5:5), lab="infinite y")
plot!([-Inf,3,4,NaN,6,7,Inf], iseven.(1:7), lab="infinite x")

issue3921

You could argue that it should have an option to draw a line to Inf, perhaps? But such an option should probably apply equally to linear and log scales.

Of course you can simulate it by clamping, but then the automatic choice of limits won't know to ignore these points:

# log
plot(clamp!(cumsum(randn(100,4), dims=1), 0.001, Inf), yaxis=(:log10, [0.1, :auto]))

# linear
plot(clamp.(inv.(-5:5), -99, 99), lab="infinite y", ylim=[-2,2])
plot!(clamp.([-Inf,3,4,NaN,6,7,Inf], -99, 99), iseven.(1:7), lab="infinite x", xlim=[0, 12])

Among recent issues about log scale, xref also #3594 about warnings for zero/negative, and #3918 about calculation of ticks when the log-scale range is small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awesome log scales discussion enhancement improving existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants