JuliaGizmos / Interact.jl

Interactive widgets to play with your Julia code
Other
520 stars 75 forks source link

Interact rounds plotted text colors to nearest black-white value #338

Open milesfrain opened 5 years ago

milesfrain commented 5 years ago

This example should show a text annotation on the over the plotted horizontal line. If the y-value of the line is even, use red text, otherwise, use green text.

using Interact, Plots, Blink

ui = @manipulate for y in slider(1:10)
    c = y % 2 == 0 ? :red : :green
    display(c)
    plot(
        [x -> y],
        0:10,
        xlims = (0,10),
        ylims = (0,10),
        annotations = (5,y,text("color annotation", color=c)),
        legend=false,
        )
end

w = Window()
body!(w, ui);

Observed behavior is that the colors are rounded to the nearest black or white value. image image

The following scatter! command will add a point to the plot and re-display it outside of interact. Now the text colors are displayed correctly.

scatter!([1],[1])

image image

Reproduced this issue in Juno and in the browser with Mux.

image image