Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving ggplot2 theme #30

Merged
merged 1 commit into from
Nov 19, 2018
Merged

Improving ggplot2 theme #30

merged 1 commit into from
Nov 19, 2018

Conversation

greimel
Copy link
Contributor

@greimel greimel commented Oct 4, 2018

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.

  • A problem is that often setting axes and ticks independently is not possible
    (axis color = white and tick color = gray)

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
Copy link
Member

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

@greimel
Copy link
Contributor Author

greimel commented Oct 13, 2018

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

GR:
scatter_gr

Problems:

  • doesn't support gridlinewidth <1
  • it's currently not possible to control "minor" ticks separately from "major" ticks

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

PyPlot is unchanged.

Problem: currently doesn't handle minor grid and ticks

@mkborregaard
Copy link
Member

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

@greimel
Copy link
Contributor Author

greimel commented Oct 16, 2018

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
Copy link
Member

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

@greimel
Copy link
Contributor Author

greimel commented Nov 19, 2018

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 JuliaPlots/Plots.jl#1850 the axis will have the correct color

scatter_pgf

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

@mkborregaard
Copy link
Member

Nice - what do you say we merge this now?

@mkborregaard
Copy link
Member

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

@greimel
Copy link
Contributor Author

greimel commented Nov 19, 2018

Which blue color?

I am fine with merging otherwise.

@greimel greimel changed the title [WIP] Improving ggplot2 theme Improving ggplot2 theme Nov 19, 2018
@mkborregaard
Copy link
Member

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
Copy link
Contributor Author

greimel commented Nov 19, 2018

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.

@greimel greimel mentioned this pull request Nov 19, 2018
2 tasks
@mkborregaard
Copy link
Member

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

@greimel
Copy link
Contributor Author

greimel commented Nov 19, 2018

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

@mkborregaard mkborregaard merged commit 959e36a into JuliaPlots:master Nov 19, 2018
@mkborregaard
Copy link
Member

Great!

@greimel greimel deleted the gre/ggplot2 branch November 19, 2018 22:02
@daschw
Copy link
Member

daschw commented Nov 20, 2018

Awesome!

@pkofod
Copy link
Collaborator

pkofod commented Nov 30, 2018

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

@isentropic
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants