-
-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
True heat maps #147
Comments
I think I agree with you... But I'd like to review the terminology that other graphics packages use to look for precedence of notation. If packages are split on the usage then I lean towards backwards compatibility. In that case maybe there's another way to distinguish the uses... Checking for matrix input maybe? Could utilize the z argument?
|
Maybe the default value of z, if z is missing, should be counts/frequencies. With a |
Looking at plotly examples, I think I agree with the proposed change:
Going along with all this, I want to overhaul the api for 3D data... namely I want to better use context of what is being plotted to determine what a vector/matrix/etc refers to: z = rand(10,10)
# this should be 10 lines:
plot(z)
# this should be a "surface"
plot(z, linetype = :contour) |
Sounds good 👍 |
|
Yeah... I had the same issue with |
Yes passing in vectors which apply to surfaces is a big (not so easy) item on my todo list.
I think these questions are tricky in the general case, so there probably needs to be additional interface that the user can specify, but maybe Plots can try to guess the right answer. If you have any ideas on proper behavior, please post. |
I was expecting something like this: Where the missing areas/points haven't colors. I believe that, by default, missing point shouldn't be plotted like in the two examples above. If that isn't possible, plot missing points with the background color (and maybe excluding the background color from the color range). Having a My favorite heatmap function from R is heatmap.2. It has the following arguments:
|
I think this is what you're going for? using Plots; plotly()
x = [1,1,1,2,2,3]
y = [2,3,4,3,4,4]
z = 1:6
# compress to unique values and remap to new indices
function remap(vals)
compressed = sort(unique(vals))
remapped = Array(eltype(x), length(vals))
for (i,x) in enumerate(compressed)
remapped[find(v -> v == x, vals)] = i
end
compressed, remapped
end
# create a matrix from the sparse representation
xs, I = remap(x)
ys, J = remap(y)
mat = full(sparse(I, J, z))
# create a gradient where (normalized) zeros are invisible
grad = ColorGradient(vcat(RGBA(0,0,0,0), Plots._gradients[:bluesreds]), [0,1e-6,0.5,1])
# plot a heatmap
heatmap(xs, ys, mat, c = grad) I think this belongs (if anything) as a recipe... not as standard behavior (but I could be convinced) |
If you can think of a good function name, and other optional settings that you'd like, I can turn this into a proper Plots recipe... |
I must admit than the If I'm having this problems with the last master: P.S.: I'm willing to replace the actual |
Your output looks really wierd. I just started up a notebook and ran: using PairwiseListMatrices, Plots; plotly()
mat = PairwiseListMatrix([1,2,-1,-3,4,0])
heatmap(mat, yflip=true) and this is what I got: Try a Also this is what I see when I add a NaN: mat[1,2] = NaN
heatmap(mat, yflip=true) |
And after checking out your current viz... that's pretty straightforward to reproduce: plotlyjs()
x = 1:4
n = length(x)
scatter(x, zeros(n), m=(10,:orange), leg=false)
zmin,zmax = extrema(mat)
grad = ColorGradient(:bluesreds)
curvecolor(v) = getColorZ(grad, (v-zmin)/(zmax-zmin))
for i=1:n, j=1:i-1
curve = BezierCurve(P2[(x[i],0), ((x[i]+x[j])/2, i-j), (x[j], 0)])
plot!(curve_points(curve), line = (curvecolor(mat[i,j]), 0.5, 2))
end |
Thanks! It works fine in the |
Could the arc diagram be a function of Plots? |
Sure... it would belong in recipes.jl. Any interest in adding it? It seems like you're into graph algos. You can use the example above as a baseline. |
I could try it :) Is there a way to plot real semicircles instead of Bézier curve? |
Two more question: |
Yes it's possible: https://plot.ly/javascript/hover-events/ I expect PlotlyJS to support this eventually. (cc: @spencerlyon2) |
@tbreloff Is It possible at this moment to access |
Well if you do: using Plots; plotlyjs()
p = plot() then |
Hey @diegozea as In this example I believe you want to alter the text/hoverinfo attribute on a particular trace. To do that you will want a call similar to: PlotlyJS.restyle!(p.o, trace_number; hoverinfo=my_hover_info, text=my_text) For more info on what |
|
What were you hoping it would be? |
Ok... Is it possible to use |
Not without some hacking. I recommend using PlotlyJS if you can. |
@tbreloff Is there a way to plot a heatmap with categorical axis labels? |
This works out of the box: julia> using Plots; plotly()
Plots.PlotlyBackend()
julia> x = ["Mon","Tues","Wed","Thur","Fri"];
julia> y = ["Morning","Afternoon","Night"];
julia> heatmap(x, y, rand(length(x), length(y)))
[Plots.jl] Initializing backend: plotly |
You can't do it directly through Plots right now (it's hardcoded). You should approach it similarly to how you did text/hover. I should add back an argument to allow for arbitrary overrides, which get merged into the Plotly dictionary before converting to JSON. Then you could add something like: |
I like |
Hi!
heatmap
are actually more like a 2D histogram plot than a real heat map.Would be great to have heatmap to take a single
Matrix
and plotting its values are colors or to take three vectors: x, y and z (color).Maybe
heatmap
with only x and y could be the actual 2D histogram or the actualheatmap
could be renamed tohistogram2D
or something similar.Best,
The text was updated successfully, but these errors were encountered: