Skip to content

Commit

Permalink
fixes handling of colour and fill aesthetics for categorical values
Browse files Browse the repository at this point in the history
  • Loading branch information
rdboyes committed Apr 3, 2024
1 parent 8effec1 commit eee32bc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/draw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ function Makie.SpecApi.Axis(plot::GGPlot)
plottable_data = geom.column_transformations[aes][2](aes, source_cols, plot_data)
elseif eltype(plot_data[!, aes_dict[a]]) <: Union{AbstractString, AbstractChar}
plottable_data = cat_inseq(aes, [aes_dict[a]], plot_data)
if aes in [:color, :fill]
plottable_data[aes] = as_color(plottable_data[aes])
end
else
plottable_data = as_is(aes, [aes_dict[a]], plot_data)
end
Expand Down
26 changes: 25 additions & 1 deletion src/transforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,30 @@ function kernel_density_2d(target::Symbol, source::Vector{Symbol}, data::DataFra
return return_dict
end

# returns nothing, removing aes from graph

function discard(target::Symbol, source::Vector{Symbol}, data::DataFrame)
return Dict{Symbol, PlottableData}()
end
end

# tweaks
# takes an existing PlottableData object and modifies the makie_function

function as_color(plottable_data_object::PlottableData)
colors = [
RGB(0/255, 114/255, 178/255), # blue
RGB(230/255, 159/255, 0/255), # orange
RGB(0/255, 158/255, 115/255), # green
RGB(204/255, 121/255, 167/255), # reddish purple
RGB(86/255, 180/255, 233/255), # sky blue
RGB(213/255, 94/255, 0/255), # vermillion
RGB(240/255, 228/255, 66/255), # yellow
]

return PlottableData(
plottable_data_object.raw,
(x -> colors[x]) plottable_data_object.makie_function,
plottable_data_object.label_target,
plottable_data_object.label_function
)
end

0 comments on commit eee32bc

Please sign in to comment.