Plots.jl icon indicating copy to clipboard operation
Plots.jl copied to clipboard

[BUG] Missing last marker when using plotly and specifying `marker_color`

Open this-josh opened this issue 1 year ago • 1 comments

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])
image

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

this-josh avatar Sep 04 '22 11:09 this-josh

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_fixis the to truebut 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

curio-sitas avatar Sep 04 '22 14:09 curio-sitas

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:

Screen Shot 2022-10-08 at 22 12 34

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.

puripant avatar Oct 08 '22 15:10 puripant