JuliaPlots / PlotThemes.jl

Themes for the Julia plotting package Plots.jl
Other
122 stars 29 forks source link

Improving ggplot2 theme #30

Closed greimel closed 5 years ago

greimel commented 6 years ago

I would like to improve the ggplot2 theme.

This is the first step.

Old :gglot2 (pyplot()) scatter_gr_old

New :ggplot2 (pyplot()) scatter_py

Main differences

  1. added 'outside ticks'
  2. no lines around markers (EDIT: added this bullet)
  3. lighter gray background. I tried to match the shades of gray according to
    R> library("ggplot2")
    R> theme_get()

    Does someone know the Juliaequivalent of grey30, grey90, etc? I translated it to grey$x == plot_color(:black, 1 - x).

Actual ggplot2 scatter_gg

Unfortunately, it is not equally nice on all backends.

Still missing:

  1. adding minor gridlines but no minor ticks (cannot be controlled independently)
  2. adding minor gridlines at all doesn't seem to be supported for some backends
  3. removing the axis altogether to remove the gap between grid and outside tick

Note: the file in the test folder will be removed eventually. I will just keep it as long as I am working on this.

mkborregaard commented 6 years ago

Great effort 👍 It's definitely not easy to get this to match on all backends, but it's a clear improvement already

greimel commented 5 years ago

with JuliaPlots/Plots.jl/pull/1787 it will look like this.

GR: scatter_gr

Problems:

(before the PR the axes looked like this: lines_gr )

PyPlot is unchanged.

Problem: currently doesn't handle minor grid and ticks

mkborregaard commented 5 years ago

Should we just merge now, or do you have other things planned here?

greimel commented 5 years ago

This depends on JuliaPlots/Plots.jl/pull/1788.

It looks good on GR and PyPlot. GR: scatter_gr

PyPlot: scatter_py

It doesn't look good on PGFPlots. It probably cannot handle plot_color(:black, 1-0.92) (to get the equivalent of R's gray92) etc. Can anyone point me where to look in order to circumvent that?

PGFPlots; scatter_pgf

I should probably fix the problem with pgfplots before this gets merged. I haven't checked with the other backends.

mkborregaard commented 5 years ago

Could you just check the rgb values of grey92 in R and specify the color as an rgb instead?

greimel commented 5 years ago

I removed the dependency on the minor-tick-PR in Plots and followed @mkborregaard's advice. The theme now look semi-nice on gr(), pyplot() and pgfplots()

scatter_gr

scatter_py

PGF

scatter_pgf

EDIT: with https://github.com/JuliaPlots/Plots.jl/pull/1850 the axis will have the correct color

scatter_pgf

Improvements (minor ticks, axis color on pgfplot) are left for future work.

mkborregaard commented 5 years ago

Nice - what do you say we merge this now?

mkborregaard commented 5 years ago

The blue color is a little off - not sure if that could be quickly fixed.

greimel commented 5 years ago

Which blue color?

I am fine with merging otherwise.

mkborregaard commented 5 years ago

Ah lol I see the palette (the colors of the points) is just Plots' default. If you see the other themes they also add palettes (see e.g. https://github.com/JuliaPlots/PlotThemes.jl/blob/94e6427befef28433bdc0dbc23d4adaa543e47aa/src/wong.jl ) so that the dots get the right color. Do you feel like adding the ggplot2 colors? I think it would improve the impression a lot. Otherwise I'm fine with merging.

greimel commented 5 years ago

I see, I found this: https://stackoverflow.com/a/8197706

Is the hcl color wheel implemented somewhere already?

I suggest merging this and leaving the rest for a separate PR.

mkborregaard commented 5 years ago

Not as such but I think it corresponds to the :isolum gradient in :colorcet, not sure that's any help though.

greimel commented 5 years ago

Ok, I'll probably tackle this at a later point. Feel free to merge this ;-)

mkborregaard commented 5 years ago

Great!

daschw commented 5 years ago

Awesome!

pkofod commented 5 years ago

Awesome! Statisticians are now less likely to be mocked for using Julia ;)

isentropic commented 4 years ago

@greimel hi, pyplot now somewhat supports the minorgrids https://github.com/JuliaPlots/Plots.jl/pull/2621 Would you mind testing the ggplot2 and see if everything works like you expect it to?