Plots.jl
Plots.jl copied to clipboard
Allow 2d coordinates for heatmap plots in PyPlot backend
Allows plotting on a non-rectangular grid, at least with PyPlot backend. For example:
using Plots
pyplot()
nx = 10
ny = 11
x = zeros(ny, nx)
y = zeros(ny, nx)
for i ∈ 1:nx, j ∈ 1:ny
x[j,i] = i
y[j,i] = 2.0 + j + i
end
z = randn(ny,nx)
heatmap(x,y,z)
savefig("test.png")
produces
Currently 'Draft' because:
- [ ]
_heatmap_edges()
is fudged for 2dx
andy
. PyPlot can handle the cell-centre/cell-edge conversion automatically so the_heatmap_edges()
functionality is not needed for the case I was trying to get working. It would be nicer to be more general, but the logic is a bit more complicated (I guess an extra argument would need to be passed to say which dimension needs to be converted from centres to edges?) - is it worth doing and does anyone have opinions/suggestions on the best way? - [ ] I guess a test would be good? I would be very grateful for a pointer on where the test should go and if there is something similar I could copy to start from.
- [ ] What to do about other backends? I tried running the same test case with GR and got an error that seemed to happen due to
z
being transposed. I got lost trying to look for where a special-case for 2dx
andy
would be needed though... Should only backends where 2dx
andy
are known to work be supported? If so where would be a good place to throw an error for unsupported backends?
Maybe an expert can see a better way to implement this and would find it easier to start from scratch, in which case please consider this just a feature request!
Codecov Report
Merging #4298 (3133ee8) into master (6d537c6) will decrease coverage by
0.18%
. The diff coverage is11.11%
.
@@ Coverage Diff @@
## master #4298 +/- ##
==========================================
- Coverage 79.92% 79.74% -0.19%
==========================================
Files 29 29
Lines 6969 6986 +17
==========================================
+ Hits 5570 5571 +1
- Misses 1399 1415 +16
Impacted Files | Coverage Δ | |
---|---|---|
src/utils.jl | 72.87% <0.00%> (-1.80%) |
:arrow_down: |
src/axes.jl | 86.27% <66.66%> (-0.16%) |
:arrow_down: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.