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 results in wrong ylim #3866

Closed
Volker-Weissmann opened this issue Oct 6, 2021 · 6 comments
Closed

[BUG] using vline results in wrong ylim #3866

Volker-Weissmann opened this issue Oct 6, 2021 · 6 comments

Comments

@Volker-Weissmann
Copy link

Volker-Weissmann commented Oct 6, 2021

Details

using Plots
p = plot()
vline!(p, [2])
plot!(p, [1,2,3], [-0.1, -0.2, -0.3])
savefig(p, "bug.pdf")

bug

The y-axis goes from -0.35 to 2, but it should go from -0.35 to 0. If you swap the order of the vline! and the plot! call, it works.

Backends

This bug occurs on ( insert x below )

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

Versions

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

Julia Version 1.6.3
Commit ae8452a9e0* (2021-09-23 17:34 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 
@BeastyBlacksmith
Copy link
Member

but it should go from -0.35 to 0

How could vline know this when there is no data available? It falls back to its default range [1,2] and then that gets expanded to fit the other data. If you know already what the range should be when calling vline you can specify by passing ylims = (0, -0.35).

@Volker-Weissmann
Copy link
Author

I could also guess that the origin was vline defaulting to [1,2].
I can't tell you how to fix the bug, without knowledge about Plots.jl architecture.

@t-bltg t-bltg closed this as completed Oct 14, 2021
@pablosaa
Copy link

pablosaa commented Feb 9, 2023

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

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

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

@t-bltg
Copy link
Member

t-bltg commented Feb 9, 2023

Could you please open a new issue ?

@AraujoH
Copy link

AraujoH commented Jul 26, 2023

I'm facing the same issue @pablosaa is facing. Adding a vline! with DateTime x-axis results in a change of values in the y-axis.

@pablosaa
Copy link

I'm facing the same issue @pablosaa is facing. Adding a vline! with DateTime x-axis results in a change of values in the y-axis.

@AraujoH you might want to update Plots.jl to version 1.38.16 or the latest 1.38.17, where that issue has been solved.

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

No branches or pull requests

5 participants