Closed diegozea closed 1 year ago
What usecases do you have in mind for this? Plots.jl already has several mechanisms for setting your own default values. What benefit would an API for a custom (private) theme give you?
It could help create personal/private themes that are easy to reuse through a codebase; maybe because you want to match the color schemes you have carefully set for your IDE, you need institutional colors, or you need it for a particular project, and you do not think it's worth it to share it. Indeed, you can already do that with the default
function; but I felt PlotThemes' API is a little nicer, as you can name themes and work with multiple ones without copying/pasting default
calls.
Makie and Gadfly have similar functionality. I think that exporting PlotTheme
will offer a solution that is similar to the one in those packages.
Indeed, you can already do that with the
default
function; but I felt PlotThemes' API is a little nicer, as you can name themes and work with multiple ones without copying/pastingdefault
calls.
Can you elaborate a bit on what is nicer API wise? Without it you could do
using Plots
my_defaults = Dict(:linewidth => 3, :markershape => :star)
default(;my_defaults...)
plot(1:5)
Maybe an additional method for default(kw::KW)
would also help?
I am fearing a bit that private themes might make people share code relying on those themes without sharing the themes and thus leading to non-reproducible code. But maybe I am overcautious here.
Thanks, I haven't thought of storing the Dict
. In that case, having the default(kw::KW)
would help, as the splat operator could be a little difficult for some newcomers to the language.
About the private themes, we can add a fallback to :default
and make theme
give a proper warning message when using :default
because of the missing theme. The same problem could happen if the Dict
is not shared (undef error).
Ok, using default
doesn't allow setting colorgradient
as in PlotThemes
:
Another point in favor of exporting PlotTheme
is that the keyword argument syntax is a lot nicer than the Dict
one.
P.S.: I have found this when writing a book chapter on theme creation with Plots, Makie, and Gadfly. The Plots example for that chapter is here: https://github.com/PacktPublishing/Interactive-Visualization-with-Julia/blob/aa36c5bc32daa7fd689db82c75b39e29657d2b94/Chapter13/plots_themes.jl At the moment, I am using the fully qualified name for PlotTheme
.
Hi! It looks like, at the moment, we need to use the
PlotTheme
type to create new themes. However, this type is not exported byPlotThemes
. Theadd_theme
function could also be great for that, but it accepts onlyPlotTheme
objects. Maybe, adding theadd_theme(name::Symbol; kargs...)
andadd_theme(name::Symbol, theme::KW)
methods could solve the problem of the missing API without requiring to exportPlotTheme
. What do you think? Cheers