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

[BUG] using vline() with DateTime as x-axis screws up the y-axis labels #4660

Closed
pablosaa opened this issue Feb 11, 2023 · 11 comments · Fixed by #4760
Closed

[BUG] using vline() with DateTime as x-axis screws up the y-axis labels #4660

pablosaa opened this issue Feb 11, 2023 · 11 comments · Fixed by #4760
Labels

Comments

@pablosaa
Copy link

Details

I found an apparently new bug using vline and DateTime format in the x-axis:
plot(rs[:time], tir[:IRT], size=(800,300))

but when adding a vline as :
vline!([DateTime(2020,4,15, 12)])
it changes the y-axis label as shown below:

I can confirm that I've worked with vline() and DateTime as x-axis data format regularly before and it used to work flawlessly before updating Plots.jl to v1.38.4 , for Julia Version 1.8.0

Backends

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) x
pythonplot x
plotlyjs x
pgfplotsx x
unicodeplots x
inspectdr x
gaston x

Versions

Plots.jl version: v1.38.4
Backend version (]st -m <backend(s)>): GR v0.71.5
Output of versioninfo():

Julia Version 1.8.0
Commit 5544a0fab76 (2022-08-17 13:38 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores
@pablosaa pablosaa added the bug label Feb 11, 2023
@ygol55
Copy link

ygol55 commented Feb 14, 2023

Can you try to do the same thing, just changing the values of the y values and x values, and using the hline!() function?

@pablosaa
Copy link
Author

If I did understand properly, you mean same plot but switching x by y axes? I did this:
plot(tir[:IRT], rs2[:time], size=(800,300)); hline!([DateTime(2020,4,15, 12)])
image
it does the right thing.

@ygol55
Copy link

ygol55 commented Feb 15, 2023

Then I think I've found the problem. That's just some typo in the code that writes the vline!() command. Here's a link for a fork of Plots.jl, where I've changed what every I thought was the problem: https://github.com/ygol55/Plots.jl, so you could run that with git

@pablosaa
Copy link
Author

Then I think I've found the problem. That's just some typo in the code that writes the vline!() command. Here's a link for a fork of Plots.jl, where I've changed what every I thought was the problem: https://github.com/ygol55/Plots.jl, so you could run that with git

Thanks for the effort. Unfortunately, using Plots from your fork is still producing still the same output.

@ygol55
Copy link

ygol55 commented Feb 19, 2023

Do you mind sending some link to the code? That's better testing it likewise.

@pablosaa
Copy link
Author

Here a minimal code that reproduces the issue:

(mytemp) pkg> st
Status `~/Downloads/temp/mytemp/Project.toml`
  [91a5bcdd] Plots v1.38.5-dev `git@github.com:ygol55/Plots.jl.git#master`
  [ade2ca70] Dates
julia> using Dates
julia> using Plots
julia> ts = range(DateTime(today()), step=Hour(1), length=24);
julia> plot(ts, 100randn(24), size=(800,300))

without_vline_dev

julia> vline!([now()])

with_vline_dev

I hope this helps better for testing.

@pablosaa
Copy link
Author

I think I've narrowed down the origin of this bug after fork the version where this bug didn't exist. The bug started after this change by @daschw has been done:
2ec18f0

I did fork https://github.com/pablosaa/Plots.jl and dismissed the changes in the link above, and the bug disappears.

@ygol55
Copy link

ygol55 commented Mar 1, 2023

It seems that the problem was with the spesific treat_y_as_x, which was only used on vline but not on hline?

@pablosaa
Copy link
Author

pablosaa commented Mar 2, 2023

It seems that the problem was with the spesific treat_y_as_x, which was only used on vline but not on hline?

not really, it is in src/arg.jl that the following line has been edited:

yformatter === :auto || (plotattributes[:xformatter] = yformatter)
xformatter === :auto || (plotattributes[:yformatter] = xformatter)

that fix the bug #4538 but unfortunately created this bug with DataTime in x-axis now. In earlier versions those two lines were only like this:

plotattributes[:xformatter] = yformatter
plotattributes[:yformatter] = xformatter

@gsalinasphys
Copy link

Any progress on fixing this bug?

@pablosaa
Copy link
Author

Any progress on fixing this bug?

No progress, unfortunately. Still the origin of this issue is on the modifications done by solving another issue #4660 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants