Skip to content

Commit

Permalink
remove plot methods now in DD
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Sep 26, 2023
1 parent 080dbf5 commit 3c3086a
Showing 1 changed file with 0 additions and 97 deletions.
97 changes: 0 additions & 97 deletions src/plotrecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,103 +234,6 @@ end

##################################################################################
# Makie.jl recipes

# For now, these are just basic conversions from 2D rasters to surface-like (surface, heatmap) plot types.
# Once Makie supports figure level recipes, we should integrate those.

# First, define default plot types for Rasters
MakieCore.plottype(raster::AbstractRaster{<:Union{Missing,Real},1}) = MakieCore.Lines
MakieCore.plottype(raster::AbstractRaster{<:Union{Missing,Real},2}) = MakieCore.Heatmap
# 3d rasters are a little more complicated - if dim3 is a singleton, then heatmap, otherwise volume
function MakieCore.plottype(raster::AbstractRaster{<:Union{Missing,Real},3})
if size(raster, 3) == 1
MakieCore.Heatmap
else
MakieCore.Volume
end
end
# plot rasters of ColorTypes as images
# define the correct plottype
MakieCore.plottype(::AbstractRaster{<:ColorTypes.Colorant,2}) = MakieCore.Image

# then, define how they are to be converted to plottable data
function MakieCore.convert_arguments(PB::MakieCore.PointBased, raster::AbstractRaster{<:Union{Real,Missing},1})
A = _prepare_makie(raster, ds)
return MakieCore.convert_arguments(PB, A, index(ds))
end
# allow 3d rasters to be plotted as volumes
function MakieCore.convert_arguments(
::MakieCore.VolumeLike, raster::AbstractRaster{<:Union{Real,Missing},3,<:Tuple{D1,D2,D3}}
) where {D1<:SpatialDim,D2<:SpatialDim,D3<:SpatialDim}
A = _prepare_makie(raster)
xs, ys, zs = lookup(A)
return (xs, ys, zs, parent(A))
end
# allow plotting 3d rasters with singleton third dimension (basically 2d rasters)
function MakieCore.convert_arguments(x::MakieCore.ConversionTrait, raster::AbstractRaster{<:Union{Real,Missing},3})
D = _series_dim(raster)
nplots = size(raster, D)
if nplots > 1
# Plot as a RasterSeries
return MakieCore.convert_arguments(x, slice(raster, D))
else
return MakieCore.convert_arguments(x, view(raster, rebuild(D, 1)))
end
end
function MakieCore.convert_arguments(
::MakieCore.SurfaceLike, raster::AbstractRaster{<:Union{Missing,Real},2,<:Tuple{D1,D2}}
) where {D1<:SpatialDim,D2<:SpatialDim}
A = _prepare_makie(raster)
xs, ys = lookup(A)
return (xs, ys, parent(A))
end
function MakieCore.convert_arguments(
::MakieCore.SurfaceLike, raster::AbstractRaster{<:ColorTypes.Colorant,2,<:Tuple{D1,D2}}
) where {D1<:SpatialDim,D2<:SpatialDim}
A = _prepare_makie(raster)
x, y = dims(A)
xs, ys, vs = DD._withaxes(x, y, A)
return (xs, ys, parent(vs))
end
function MakieCore.convert_arguments(
::MakieCore.DiscreteSurface, raster::AbstractRaster{<:Union{Missing,Real},2,<:Tuple{D1,D2}}
) where {D1<:SpatialDim,D2<:SpatialDim}
A = _prepare_makie(raster)
xs, ys = map(_lookup_edges, lookup(A))
return (xs, ys, parent(A))
end
function MakieCore.convert_arguments(
::MakieCore.DiscreteSurface,raster::AbstractRaster{<:ColorTypes.Colorant,2,<:Tuple{D1,D2}}
) where {D1<:SpatialDim,D2<:SpatialDim}
A = _prepare_makie(raster)
xs, ys = map(_lookup_edges, lookup(A, (X, Y)))
return (xs, ys, parent(A))
end
function MakieCore.convert_arguments(x::MakieCore.ConversionTrait, series::AbstractRasterSeries)
return MakieCore.convert_arguments(x, first(series))
end
# fallbacks with descriptive error messages
MakieCore.convert_arguments(t::MakieCore.ConversionTrait, r::AbstractRaster) =
_makie_not_implemented_error(t, r)

function _makie_not_implemented_error(t, r::AbstractRaster{T,N}) where {T,N}
@error """
We don't currently support plotting Rasters of eltype $T, with $N dimensions, as
a $t type plot in Makie.jl.
In order to plot, please provide a 2-dimensional slice of your raster contining
only `Real` and `Missing` values.
For example, in a 3-dimensional raster, this would look like:
```julia
myraster = Raster(...)
heatmap(myraster) # errors
heatmap(myraster[Ti(1)]) # use some index to subset, this works!
```
"""
end

# initial definitions of `rplot`, to get around the extension package availability question

function rplot(args...)
Expand Down

0 comments on commit 3c3086a

Please sign in to comment.