Skip to content
Snippets Groups Projects
Commit 0a19e472 authored by Julian Stürmer's avatar Julian Stürmer
Browse files

Add marker for zero values in scatter plot

parent 6e69128d
No related branches found
No related tags found
No related merge requests found
......@@ -46,16 +46,20 @@ function scatter_branchloads(
### Scatter branch loads versus each other
diff = y_bl - x_bl # deviation from ratio 1 for coloring
mcolors = pyimport("matplotlib.colors")
offset = mcolors.TwoSlopeNorm(
vcenter=0, vmin=minimum(diff), vmax=maximum(diff)
) # match diff to values between 0 and 1
diff[diff .== 0.0] .= -10 # map exact zero values to -10 for distinct color
# mcolors = pyimport("matplotlib.colors")
# offset = mcolors.TwoSlopeNorm(
# vcenter=0, vmin=minimum(diff), vmax=maximum(diff)
# ) # match diff to values between 0 and 1
cmap = plt.get_cmap(settings["cmap"])
cmap.set_under("tab:green")
sc = plt.scatter(
x_bl, y_bl,
s = settings["size"],
c = offset(diff),
c = diff,
# c = offset(diff),
cmap = cmap,
vmin = -1.,
vmax = 1.,
edgecolors = settings["ec"],
linewidths = settings["lw"],
......@@ -63,8 +67,11 @@ function scatter_branchloads(
)
### Add colorbar
sm = plt.cm.ScalarMappable(cmap=cmap, offset)
sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(-1., 1.))
# sm = plt.cm.ScalarMappable(cmap=cmap, offset)
cbar = plt.colorbar(sm)
cbar.ax.plot([-1, 1], [0.0, 0.0], "tab:green")
# cbar.add_lines(CS2)
cbar.ax.set_ylabel(
L"Difference $y-x$", rotation=-90, va="bottom"
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment