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

Automatic Adaptive Plotting of Functions Needs Work #4106

Closed
oscarrutt opened this issue Feb 17, 2022 · 5 comments · Fixed by JuliaPlots/PlotUtils.jl#137
Closed

Automatic Adaptive Plotting of Functions Needs Work #4106

oscarrutt opened this issue Feb 17, 2022 · 5 comments · Fixed by JuliaPlots/PlotUtils.jl#137
Labels
enhancement improving existing functionality

Comments

@oscarrutt
Copy link

oscarrutt commented Feb 17, 2022

The adaptive function plotter in Julia is not very robust and can't be trusted even with simple functions. Consider the following simple cases made with Julia 1.6.3 and the gr backend.

Consider the following function:

function p(x::Float64)
    if x < 0.0 || x > 1.0
        return 0.0;
    else
        return 1.0 + x;
    end
end;

Then the following bit works OK:

k = 2.0;
s = 2.0;
plot(x -> p(k * (x - s)))

with this result:

yay s = 2
but this bit

k = 2.0;
s = 3.0;
plot(x -> p(k * (x - s)))

fails as such
oops s = 3
For another failure on a simple plot, consider

plot(sinc, xlims = (0.0, 30.0))

which looks nice
yay sinc
but simply changing the plot limits

plot(sinc, xlims = (0.0, 40.0))

causes this failure:
oops sinc

@oscarrutt oscarrutt added the bug label Feb 17, 2022
@t-bltg
Copy link
Member

t-bltg commented Feb 18, 2022

Related: #3894.

@oscarrutt
Copy link
Author

@t-bltg Thanks. Let's make sure we don't get hung up on sinc. It's not hard to find failing cases.

plot(x -> cos(20.0 * x) * exp(-x), xlims = (0.0, 10.0))

And it's not just oscillating functions; my first example didn't display a plot at all, and that's a super simple function.

I saw a thread from a few years ago where the devs were trying to mimic Mathematica's adaptve plotter. This isn't finished work.

@BeastyBlacksmith
Copy link
Member

That function lives here and improvements are welcome!

@BeastyBlacksmith BeastyBlacksmith added enhancement improving existing functionality and removed bug labels Feb 18, 2022
@oscarrutt
Copy link
Author

@BeastyBlacksmith How is this not a bug? Please reconsider.

@t-bltg
Copy link
Member

t-bltg commented Feb 19, 2022

@BeastyBlacksmith How is this not a bug? Please reconsider.

This is not a bug per se, but a limitation in the mentioned algorithm: we only need a finer / better distributed 1D grid for evaluating the functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improving existing functionality
Projects
None yet
3 participants