Plots.jl
Plots.jl copied to clipboard
[BUG] Missing last marker when using plotly and specifying `marker_color`
Details
The following code doesn't have a circle for the final data point
using Plots
plotly()
a= [1,2,3,25]
b = [25,9,8,4]
plot(a, b, markershape=:circle, markercolor=[1,2,3,4])
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: v1.31.7
Backend version (]st -m <backend(s)>
):
Output of versioninfo()
:
Julia Version 1.8.0
Commit 5544a0fab76 (2022-08-17 13:38 UTC)
Platform Info:
OS: macOS (arm64-apple-darwin21.3.0)
CPU: 10 × Apple M1 Max
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
Threads: 8 on 8 virtual cores
The problem comes from the fact that the plot draws over segments. For N points there is N-1 segment. But the renderer draws one marker per segment, so we miss the last one.
For a plot series with scatter option, the needs_scatter_fix
is the to true
but it may not behave correctly.
src/backends/plotly.jl
at line 908 :
:color => needs_scatter_fix ? [mcolor, "rgba(0, 0, 0, 0.000)"] : mcolor
The last marker is transparent.
One could change the way the plot is contructed in this configuration or add an null segment to draw the last marker
I am new to this repo but I would like to contribute for the first time. Thanks to the pointers by @curio-sitas I can fix this bug and create the following screenshot:
However, I do it another way by checking if it is the last segment and then setting the last marker as non-transparent. If this sounds okay, I will send a pull request.