You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to have a NaN separated series for paths, in which color changes for each part of the path.
For instance x, y, z are vectors, with some NaN separating the different lines of the tree; say x = [0.1, 0.2, 0.3, NaN, 0.1, 0.2], y = [0.5, 0.4, 0.5, NaN, 0.5, 0.6] and z = [0.2, 0.8, 0.6, NaN, 0.1, 0.9]. I would like each of the series to have the corresponding path colored according to z. This would work if there are no NaN separating the paths, but it does not work when NaN's are included. I raised the issue on slack (https://julialang.slack.com/archives/C8JKM4JQ6/p1599257009014800) and I got an answer to use the @series macro, but it becomes prohibitively slow.
It is fast If I do not put NaN's (though this is not what I want, the diagonal lines should not appear). Note that the color changes along the branches of the tree:
or if I don't try to color the segments:
Any help of making this possible would be very appreciated! Thanks.
My current recipe is (note the commented section which does what I want but takes very long using the @series macro):
@recipe function f(tree::iTgbm, zfun::Function)
x = Float64[]
y = Float64[]
z = Float64[]
rplottree(tree, treeheight(tree), 1:sntn(tree), zfun, x, y, z)
pop!(x)
pop!(y)
pop!(z)
# plot defaults
line_z --> z
linecolor --> :inferno
legend --> :none
colorbar --> true
xguide --> "time"
fontfamily --> font(2, "Helvetica")
xlims --> (0, treeheight(tree))
ylims --> (0, sntn(tree)+1)
xflip --> true
xtickfont --> font(8, "Helvetica")
grid --> :off
xtick_direction --> :out
yshowaxis --> false
# nan_inds = findall(x -> isnan(x),z)
# for i in eachindex(nan_inds)
# start = 1 + (i == 1 ? 0 : nan_inds[i - 1])
# stop = nan_inds[i] - 1
# @series begin
# line_z --> z[start:stop]
# x[start:stop], y[start:stop]
# end
# end
return x, y
end
The text was updated successfully, but these errors were encountered:
ignacioq
changed the title
[FR] NaN-seperated series with changing colors
[FR] NaN-separated series with changing colors
Sep 7, 2020
@ignacioq Can you check if the problem is solved in Plots master?
The code you pasted here doesn't seem to be complete so I can't test it, but I think this should be fixed by #3320.
Where x and y are the coordinates for the lines and z should be the color. However, the lines are plotted only with the first color of the segment. If you remove the NaN, then the colors do change within each segment but then they are connected to each other.
I would like to have a NaN separated series for paths, in which color changes for each part of the path.
![t1](https://user-images.githubusercontent.com/5589248/92416816-eae1ba80-f124-11ea-8c50-8f2b52ef8ea9.png)
![t0](https://user-images.githubusercontent.com/5589248/92416814-e74e3380-f124-11ea-9ef8-73ca38acc816.png)
For instance x, y, z are vectors, with some NaN separating the different lines of the tree; say
x = [0.1, 0.2, 0.3, NaN, 0.1, 0.2]
,y = [0.5, 0.4, 0.5, NaN, 0.5, 0.6]
andz = [0.2, 0.8, 0.6, NaN, 0.1, 0.9]
. I would like each of the series to have the corresponding path colored according toz
. This would work if there are noNaN
separating the paths, but it does not work when NaN's are included. I raised the issue on slack (https://julialang.slack.com/archives/C8JKM4JQ6/p1599257009014800) and I got an answer to use the@series
macro, but it becomes prohibitively slow.It is fast If I do not put NaN's (though this is not what I want, the diagonal lines should not appear). Note that the color changes along the branches of the tree:
or if I don't try to color the segments:
Any help of making this possible would be very appreciated! Thanks.
My current recipe is (note the commented section which does what I want but takes very long using the
@series
macro):The text was updated successfully, but these errors were encountered: