Is it possible under PlotlyJS
to add hlines on “y#” (e.g. “y2”)?
Here my sample code:
using PlotlyJS
# ---
function plot_debug_hline()
scatter1 = PlotlyJS.scatter(;y = [ 1, 2, 3, 4], name= "Y1")
scatter2 = PlotlyJS.scatter(;y = [+2.5, +1.5, 0.5, -1.5], name= "Y2", yaxis= "y2")
plt_traces = [scatter1, scatter2]
plt_layout = PlotlyJS.Layout(
title_text = "Debug add_hline!()",
xaxis_title_text = "xaxis title",
yaxis_title_text = "yaxis title",
yaxis2 = PlotlyJS.attr(
title = "yaxis2 title",
overlaying = "y",
side = "right",
),
)
# ---
_fig_obj = PlotlyJS.Plot(plt_traces, plt_layout)
PlotlyJS.add_hline!(_fig_obj, 2; line_color = "blue", line_dash = "dash", line_width = 1)
PlotlyJS.add_hline!(_fig_obj, 1.5; line_color = "red", line_dash = "dash", line_width = 1, yaxis = "y2")
# PlotlyJS.add_hline!(_fig_obj, 1,5; line_color = "green", line_dash = "dash", line_width = 1, yref = "y2") # "yref" does not work :-(
# ---
return _fig_obj
end
fig_obj = plot_debug_hline()