Open piever opened 3 years ago
I agree, should be straightened out. What do you like better? I think it's quite hard to name it so it's immediately clear what's meant. I like if the symbols :x and :y are used just because they're short. But maybe horizontal and vertical are clearer because they imply more of an orientation? A barplot that goes along the y axis is what I would call a horizontal barplot. But I would call a density that goes along the x axis horizontal 🤔
I see your point... It is even worse with things like density
versus violin
...
I think that this attribute should determine how the vectors that the user passes are mapped to the axes, to allow for reliable labeling. I see two ways forward.
plot(T, x)
means plot x
on the y
axisplot(T, x, y)
means plot x
on the x
axis, y
on the y
axisWe go with orientation = :vertical
for things that respect the default, orientation = :horizontal
for those who don't. In particular, density
and histogram
would have horizontal
orientation by default (which represents how we plot them at the moment). This makes a reasonable amount of sense, in that for example a orientation = :horizontal
density plot would be fully consistent with orientation = :horizontal
violin.
plot(T, x)
means plot x
on the x
axisplot(T, x, y)
means plot x
on the x
axis, y
on the y
axisIn this case, I would call the attribute something like flip
, transpose
, or permutedims
. The only odd thing is that scatter(rand(10))
does not respect this criterion, so it would have to set flip = true
by default. If we go for this, I suspect we should just stop the automatic conversion rand(10) -> (1:10, rand(10))
.
I like option 1, possibly with the option do do orientation = :flip
, which would give you whichever of [:horizontal, :vertical]
is not the default for that plot type
In three dimensions, there are more options than just "flipped" and "not flipped". "Permuted dims" may be right abstraction.
I'm not an Makie expert. But perhaps a look from the "outside" may help a bit. I did a comparison of (now four) Julia graphics packages on creating statistical plots (see: https://github.com/roland-KA/StatisticalPlotsWithJulia).
It was not quite easy for me to figure out that direction = :x
is the way (using Makie/AlgebraOfGraphics) to turn a bar plot from it's vertical layout into a horizontal position (apart from the problems I had to get useful ticks and labels on the x- and y-axis).
Other packages use the following:
Geom.bar(orientation = :horizontal)
orientation = :hor
x
and y
are simply exchanged (i.e. the categorical data dimension is assigned to y
and the numerical data dimension is assigned to x
).(You can also use orientation = :horizontal
with Plots)
(You can also use
orientation = :horizontal
with Plots)
So using orientation = :horizontal
in Makie as well would create a consistency across three graphics packages in the Julia universe, which could be helpful in understanding and using the package.
Makie differs in many ways from Plots, I think it's more important to get the API right than similar to another package.
How about abstracting the symbols away into new type instances (with a mapping function that maps previous symbols to those new type instances and informs about the deprecatedness)? That way we have a clear decoupling from all other packages.
For extensibility towards more dimensions one could make it an interface that needs to provide a function that maps/reorders arguments to axes. Then, always plot with the first argument to the right and the 2nd upwards as the dimensions are indexed in mathematics.
But at the same time we then should move away from xtick and ytick and instead call it something different since they should also follow the plot-orientation.
It seems there's a bit of a split in the API between
orientation = :horizontal, :vertical
ordirection = :x, :y
https://github.com/JuliaPlots/AbstractPlotting.jl/search?q=direction
https://github.com/JuliaPlots/AbstractPlotting.jl/search?q=orientation
Happy to make a PR to fix it if we agree on which ones to change.