Skip to content

Commit

Permalink
Merge pull request #118 from NREL-Sienna/jd/negative_values
Browse files Browse the repository at this point in the history
add sign detection for negative traces
  • Loading branch information
jd-lara authored Feb 26, 2024
2 parents 8060e16 + b0958b1 commit 34d1509
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/plotly_recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,15 @@ function _dataframe_plots_internal(
if bar
plot_kwargs[:marker_color] = seriescolor[ix]
end
data_to_plot = plot_data[:, ix]
if sum(data_to_plot) >= 0
sign_group = 0
else
sign_group = 10
end

if stack
plot_kwargs[:stackgroup] = string(plot_length + 1)
plot_kwargs[:stackgroup] = string(plot_length + 1 + sign_group)
if nofill
plot_kwargs[:fillcolor] = "transparent"
else
Expand All @@ -84,7 +91,6 @@ function _dataframe_plots_internal(
end
plot_kwargs[:line_color] = seriescolor[ix]
plot_kwargs[:name] = names[ix]

trace = Plots.PlotlyJS.scatter(; y = plot_data[:, ix], plot_kwargs...)
push!(traces, trace)
end
Expand All @@ -94,7 +100,7 @@ function _dataframe_plots_internal(
layout_kwargs[:xaxis] =
Plots.PlotlyJS.attr(; showticklabels = !bar, title = "$time_interval")
layout_kwargs[:title] = "$title"
layout_kwargs[:barmode] = stack ? "stack" : "group"
layout_kwargs[:barmode] = stack ? "relative" : "group"
merge!(layout_kwargs, kwargs)
Plots.PlotlyJS.relayout!(plot, Plots.PlotlyJS.Layout(; layout_kwargs...))

Expand Down

0 comments on commit 34d1509

Please sign in to comment.