Git Product home page Git Product logo

ggeasy's Introduction

ggeasy

Covrpage Summary Travis build status AppVeyor build status R-CMD-check Codecov test coverage CRAN status

You know how to make ggplot2 graphics, right? No worries. Piece of cake.

Now, can you please rotate the x axis labels to vertical?

ggeasy is here to make that a little easier.

Installation

You can install the latest released version of ggeasy from CRAN with:

install.packages("ggeasy")

or the bleeding-edge development version from GitHub with

# install.packages("remotes")
remotes::install_github("jonocarroll/ggeasy")

Reference

See the pkgdown site.

@amrrs a.k.a. @1littlecoder has produced a video walkthrough using ggeasy which covers some of the major features:

Watch the video

Sharon Machlis has a great article detailing using the package, as well as a video

Watch the video

Examples

library(ggplot2)
library(ggeasy)

# rotate x axis labels
ggplot(mtcars, aes(hp, mpg)) + 
    geom_point() + 
    easy_rotate_x_labels()

# rotate y axis labels
ggplot(mtcars, aes(hp, mpg)) + 
    geom_point() + 
    easy_rotate_y_labels()

# remove 'size' legend
ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
    geom_point() +
    easy_remove_legend(size)

# make the x axis labels larger
ggplot(mtcars, aes(mpg, hp)) +
  geom_point() +
  easy_x_axis_labels_size(22)

# make all the text red
ggplot(mtcars, aes(mpg, hp)) +
  geom_point(aes(fill = gear)) +
  easy_all_text_color("red")

# remove just x axis
ggplot(mtcars, aes(wt, mpg)) +
  geom_point() + 
  easy_remove_x_axis()

# remove y axis ticks
ggplot(mtcars, aes(wt, mpg)) +
  geom_point() + 
  easy_remove_y_axis(what = "ticks")

# move legends to bottom
ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
  geom_point() + 
  easy_move_legend("bottom")

# move legend to left side
ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
  geom_point() +
  easy_legend_at("left")

# Make legends horizontal
ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
  geom_point() + easy_rotate_legend("horizontal")

# use labelled variables
iris_labs <- iris
labelled::var_label(iris_labs$Species) <- "Flower\nSpecies"
labelled::var_label(iris_labs$Sepal.Length) <- "Length of Sepal"
iris_labs_2 <- iris_labs
labelled::var_label(iris_labs_2$Species) <- "Sub-genera"

# use variable labels automatically
ggplot(iris_labs, aes(x = Sepal.Length, y = Sepal.Width)) +
    geom_line(aes(colour = Species)) + 
    geom_point(data = iris_labs_2, aes(fill = Species), shape = 24) +
    easy_labs()

These functions will try to teach you the ‘official’ way to achieve these goal, usually via the teach argument (where implemented)

ggplot(mtcars, aes(hp, mpg)) + 
    geom_point() + 
    easy_rotate_y_labels(angle = "startatbottom", teach = TRUE)
#> easy_rotate_y_labels call can be substituted with:
#> theme(axis.text.y = element_text(angle = 90, hjust = 0))

ggplot(mtcars, aes(wt, mpg)) +
  geom_point() + 
  easy_remove_y_axis(what = "ticks", teach = TRUE)
#> easy_remove_y_axis call can be substituted with:
#> theme(axis.ticks.y = element_blank())

Credits

Many thanks to Sébastien Rochette (@statnmap) for the design and execution of the hex logo.

ggeasy's People

Contributors

aliciaschep avatar feddelegrand7 avatar hrbrmstr avatar jonocarroll avatar yonicd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ggeasy's Issues

Add GH Action for pkgdown

Site is currently out of date (I forgot to rebuild) but GH Actions should be taking care of that.

There's probably a recipe for it already in usethis.

A grammar of graphics details?

I was just wondering if it is worth designing and defining an formal or semi-formal grammar for these function names, so that they are readily guessable without having to look them up? In other words, a naming convention, such as, based on what has been done so far, [prefix][axis-qualifier][attribute|verb].

Or, rather than having to define a zillion easy_ functions, what about one function that uses a little DSL to set the theme attributes? No need to mess with lex and yacc (which are available in R via the rly package btw), it might be enough just to pass commands and scalars as ellipsis arguments eg

ggdetails("x", "axis", "blue")

or, equivalently,

ggdetails("blue", "x", "axis")

or, using a lexer (eg rly) to tokenise a single string argument:

ggdetails("blue x axis")

or

ggdetails("x axis blue")

This also makes it easier for users who are non-native English speakers, whose natural word-ordering assumptions may be different - order would not matter.

The order of the ellipsis arguments or tokens wouldn't matter because the class of the argument or token can be inferred from its value in the very constrained context of the ggdetails() function. "axis", "legend", "text" can only refer to plot elements, "blue", "orange" or a hex RGB value can only refer to colours, and "2" or "5" are scalars (for font size or rotation), and "+25%" or "-33%" means increase or decrease current size (or whatever is specified by 25% or 33% respectively. That way argument order doesn't need to be remembered.

Actually, using yacc and lex via rly to build a simple DSL might be the best option, but the utility of the concept could be tested using individual ellipsis arguments to start with.

Document _PACKAGE

To comply with the following email:

Dear maintainer,

You have file 'ggeasy/man/ggeasy.Rd' with \docType{package}, likely
intended as a package overview help file, but without the appropriate
PKGNAME-package \alias as per "Documenting packages" in R-exts.

This seems to be the consequence of the breaking change

Using @doctype package no longer automatically adds a -package alias.
Instead document _PACKAGE to get all the defaults for package
documentation.

in roxygen2 7.0.0 (2019-11-12) having gone unnoticed, see
r-lib/roxygen2#1491.

As explained in the issue, to get the desired PKGNAME-package \alias
back, you should either change to the new approach and document the new
special sentinel

"_PACKAGE"

or manually add

@Aliases ggeasy-package

if remaining with the old approach.

Please fix in your master sources as appropriate, and submit a fixed
version of your package within the next few months.

Best,
-k

we should update https://github.com/jonocarroll/ggeasy/blob/master/R/ggeasy-package.r to document a _PACKAGE sentinel, and submit to CRAN.

Release ggeasy 0.1.4

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push

API change: `easy_plot_title_size` should be called `easy_title_size` etc

I think the use of "plot" in function names is unnecessary, makes the function names too long, and be more difficult to find/guess the function name for new users.

E.g. I want to remove the title or subtitle. I wouldn't even know that that is called a plot.title or plot.subtitle in ggplot2 language. The teach = TRUE can tell people what this is in ggplot2 language.

So I think that easy_plot_title_size should be called easy_title_size instead - with the former deprecated.

This applies to the following functions:
image

Reverse Legend Order

When creating a horizontal grouped bar chart the order in the legend does not match the order of the bars in the plot.

library(ggplot2)
library(dplyr)

p <- mtcars %>%
  group_by(cyl, am) %>%
  summarise(n = n()) %>%
  ggplot(aes(cyl, n, fill = factor(am))) +
  geom_col(position = "dodge") +
  coord_flip()

image

Changing this involves some functions I almost never use (and thus always forget).

p + guides(fill = guide_legend(reverse = TRUE))

image

My proposal is to have something like easy_reverse_legend(). What do you think @jonocarroll?

Set vjust in easy_rotate_x_labels()?

The default vjust looks a bit awkward to me. I know I can set with #18, what's a good default?

library(tidyverse)

data <- tibble(a = 1:3)
data %>%
  ggplot(aes(a, a)) +
  geom_point() +
  ggeasy::easy_rotate_x_labels()

data %>%
  ggplot(aes(a, a)) +
  geom_point() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))

Created on 2020-07-05 by the reprex package (v0.3.0)

image links broken on ghpages

A lot of the image links are broken in the homepage of the site.

I think that pkgdown expects the outputs to be in man/figures (currently fig.path = "tools/readme/README-") to copy them right for the site.

Installation failed

Could you please help me with this installation error?

* installing *source* package 'ggeasy' ...
** R
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
*** arch - i386
Error: package or namespace load failed for 'ggeasy':
 object 'ggplot_add' not found whilst loading namespace 'ggeasy'
Error: loading failed
Execution halted
*** arch - x64
Error: package or namespace load failed for 'ggeasy':
 object 'ggplot_add' not found whilst loading namespace 'ggeasy'
Error: loading failed
Execution halted

Feature request: easy functions should work on more specific theme elements

Lots of theme elements might have more specific theme elements specified than that which the ggeasy function affects.

In these cases, the ggeasy function does not work - and users will often be confused.

Ideally it would just work regardless of the theme elements already specified - as the user just wants to remove them all.

An idea is to have an argument within these easy functions to be as specific as possible.

I'm thinking a specific = TRUE argument - or a broad = FALSE argument.

Not sure whether it would default to being specific or not. That would depend if your priority was teaching users, or just doing what the user wants to do. I'd vote for just working being the priority. I know how ggplot2 theme statements work, but I prefer to just use ggeasy.

For example, with easy_remove_y_axis(what = "text", specific = TRUE) or equivalent argument, it would add:

theme(axis.text.x.bottom = element_blank(), axis.text.x.top = element_blank())

library(tidyverse)
library(palmerpenguins)

penguins |> 
  ggplot() +
  geom_point(aes(x = flipper_length_mm, body_mass_g)) +
  hrbrthemes::theme_ipsum() +
  ggeasy::easy_remove_axes()
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).
#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
#> not found in Windows font database

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
#> not found in Windows font database
#> Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
#> font family not found in Windows font database

#> Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
#> font family not found in Windows font database

#> Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
#> font family not found in Windows font database

Created on 2024-02-15 with reprex v2.1.0

Print the relevant code

These helpers are going to be great, but I don't want people to have to rely on them. We could have an optional argument to everything (e.g. teach = TRUE) which, when activated, prints the actual command (the hard one) to the console. Maybe we can tee this to a bquote() or something so we don't have to write it out manually.

i.e.

p + easy_rotate_x_labels(teach = TRUE)
#> To build this yourself, use: 
#>   + theme(axis.text.x = element_text(angle = 90, hjust = 0))

Labellers

I just recently discovered some of the useful labelling functions in ggplot for labelling facets, e.g. "label_both" and "label_wrap_gen". I think it could be nice to have some additional labellers.

?as_labeller brings up some nice examples of a few labellers:

p <- ggplot(mtcars, aes(disp, drat)) + geom_point()
p + facet_wrap(~am)

# Rename labels on the fly with a lookup character vector
to_string <- as_labeller(c(`0` = "Zero", `1` = "One"))
p + facet_wrap(~am, labeller = to_string)

# Quickly transform a function operating on character vectors to a
# labeller function:
appender <- function(string, suffix = "-foo") paste0(string, suffix)
p + facet_wrap(~am, labeller = as_labeller(appender))

Both the to_string and appender (and prepender) could be nice (with to_string made into more general function that takes integers and converts to the word).

Another type of labeller I think would be useful would be something that takes snake_case or period.case into separate words. I find that I often use gather before ggplot and then end up with a column where the variables are in snake_case because the column name were snake_case. While that fix can happen in that data pre-processing, it could also be nice as a labeller if you only care about the transformation in context of plotting.

facets fail on polar coords above x number of rows

This code works:

library(tidyverse)
gapminder::gapminder %>% head(100) %>% 
  ggplot(aes(x = year, y = lifeExp)) + 
  geom_line() + coord_polar() +
  facet_wrap(~country) + theme_minimal() +
  ggeasy::easy_remove_axes()

but this fails to plot on my machine:

gapminder::gapminder %>% head(500) %>% 
  ggplot(aes(x = year, y = lifeExp)) + 
  geom_line() + coord_polar() +
  facet_wrap(~country) + theme_minimal() +
  ggeasy::easy_remove_axes()

The threshold seems to be exactly 200, but I have no idea why.

Feature request: `easy_panel_spacing` function

Great package!

It'd be cool to have a function that easily adjusts the panel spacing.

So code that does this in an easy way.

library(palmerpenguins)
library(tidyverse)

p <- penguins |>
  ggplot() +
  geom_histogram(aes(x = flipper_length_mm)) +
  facet_grid(sex ~ species)

p + 
  theme(panel.spacing = grid::unit(1.25, "lines"))
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_bin()`).

p + 
  theme(panel.spacing.x = grid::unit(1.25, "lines"))
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_bin()`).

p +
 theme(panel.spacing.y = grid::unit(1.25, "lines"))
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_bin()`).

Created on 2023-08-24 with reprex v2.0.2

[New Functionality]: Control size, color, font, etc for "strip" (for facets/grids charts).

Hello,

Thanks a lot for your effor with this package.
It really makes very easy to deal with ggplot2.

I am using very frequently charts with facets and I miss a lot a way to customize in particular the strip element as easy as we can already deal with other ggplot's elements. Thinks like changing the color, the kind of font, its size, etc, in an easy way would be very much appreciated.

Thanks in advance,
Carlos.

Feature request: new `easy_remove_axes_line_ticks`, `easy_remove_x_axis_line_ticks` and `easy_remove_y_axis_line_ticks` functions

A common thing to do to make a pretty graph for presentation is to remove the axis line and ticks from one axis. It looks pretty nice and minimalist.

It'd be great if ggeasy could provide some shortcut functions for these functions to reduce typing. Some ideas of what to call them here. I think you could avoid the reference to ticks in the name, on the assumption that everyone who would want to remove the line would also like to remove the ticks
easy_remove_axes_line_ticks <- easy_remove_axes(c("line", "ticks"))
easy_remove_x_axis_line_ticks <- easy_remove_x_axis(c("line", "ticks"))
easy_remove_y_axis_line_ticks <- easy_remove_y_axis(c("line", "ticks"))

library(tidyverse)
library(ggblanket) #development version
library(palmerpenguins)
library(ggeasy)

penguins |>
  mutate(across(sex, \(x) stringr::str_to_sentence(x))) |> 
  gg_point(
    x = flipper_length_mm,
    y = body_mass_g,
    col = species,
  ) +
  easy_remove_y_axis(c("line", "ticks"))
#> Warning in gg_blanket(data = data, geom = "point", stat = stat, position = position, : Ignoring unknown parameters: `contour`
#> Ignoring unknown parameters: `contour`
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).

Created on 2024-02-09 with reprex v2.1.0

Background colours/transparent

Inspired by @kamalakaze - I'd welcome a PR from you if you'd like to be listed an author here.

https://github.com/kamalakaze/ggeasy/blob/master/R/colors.R

I'd also highly recommend something like easy_transparent() which sets

panel.background = element_rect(fill = "transparent", colour = NA),
plot.background = element_rect(fill = "transparent", colour = NA),
legend.background = element_rect(fill = "transparent", colour = NA),
legend.box.background = element_rect(fill = "transparent", colour = NA)

Feature request: `easy_background_fill` function

easy_background_fill(what = c("plot", panel", "legend", "key"), to = NULL, teach = FALSE)

where to is the fill colour hex code (or colour name)

library(palmerpenguins)
library(tidyverse)
#> Warning: package 'ggplot2' was built under R version 4.3.1
#> Warning: package 'purrr' was built under R version 4.3.1
#> Warning: package 'dplyr' was built under R version 4.3.1

p <- penguins |> 
  ggplot() +
  geom_point(aes(flipper_length_mm, body_mass_g, colour = species))

p +
  theme(plot.background = element_rect(fill = "green")) +
  theme(panel.background = element_rect(fill = "red")) +
  theme(legend.background = element_rect(fill="orange")) +
  theme(legend.key = element_rect(fill = "blue"))
#> Warning: Removed 2 rows containing missing values (`geom_point()`).

Created on 2023-09-20 with reprex v2.0.2

Recognize color besides colour

library(ggplot2)
df = data.frame(my_x=1, my_y=2, my_col=3)
p <- ggplot(df, aes(x=my_x, y=my_y, color=my_col)) + geom_point()
print(p + labs(colour = "works, too"))
print(p + labs(color = "works"))
print(p + ggeasy::easy_labs(colour = "works, yeah"))
print(p + ggeasy::easy_labs(color = "does not work"))

Ergo, ggeasy::easy_labs does not recognize color, while ggplot2::labs does.

easy rotate y-axis labels

I noticed the x labels were in your commits. As far as I know there isn't a helper function for the $y$-axis labels? This came up for me recently when I was doing a coord flip.

Feature request: `easy_gridlines_colour` function

easy_gridlines_colour(axis = c("both", "x", "y"), minor = TRUE, major = TRUE, to = NULL, teach = FALSE)

where to is the colour hex code (or colour name)

library(palmerpenguins)
library(tidyverse)
#> Warning: package 'ggplot2' was built under R version 4.3.1
#> Warning: package 'purrr' was built under R version 4.3.1
#> Warning: package 'dplyr' was built under R version 4.3.1

p <- penguins |> 
  ggplot() +
  geom_point(aes(flipper_length_mm, body_mass_g, colour = species))

p +
  theme(panel.grid.major = ggplot2::element_line(colour = "red")) +
  theme(panel.grid.major.x = ggplot2::element_line(colour = "blue"))
#> Warning: Removed 2 rows containing missing values (`geom_point()`).

Created on 2023-09-20 with reprex v2.0.2

coord flip legends in coord flip plots

On the banner on my twitter account (cantabile) I've got a vis where I've coord flipped but the legend didn't. Is there an easy way to do this? Can we manipulate elements of a legend?

John MacKintosh suggested this resource. Looks like a good place to get started.

remove legend(s)

There are multiple ways to remove specific legends but it can be hard to remember and is frequently looked up on stackoverflow:

https://stackoverflow.com/questions/14604435/turning-off-some-legends-in-a-ggplot

ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
  geom_point() + guides(size=FALSE)

and

ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
  geom_point() + scale_size(guide = FALSE)

both work to remove just the size scale.

The idea here would be to add

ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
  geom_point() + easy_remove_legend(size)

The easy_remove_legend function would take zero, one, or more names of legends to remove (e.g. fill, color, size, shape). With zero, all legends would be removed (theme(legend.position = "none")).

This would be easy to implement (and I am happy to do it myself), but perhaps removing legends isn't tricky enough for inclusion in this package -- thoughts?

Feature request: more quick functions for removing axis content

I think it'd be super useful to have more quick functions to remove axes content. With the autocomplete, this makes it quicker and easier to add what you want.

It'd also to cool to have a variant for removing the lines and ticks, as this is a common thing to remove both.

Sorry to bombard you with feature ideas!

ggeasy::easy_remove_x_title()
ggeasy::easy_remove_y_title()
ggeasy::easy_remove_axes_title()

ggeasy::easy_remove_x_text()
ggeasy::easy_remove_y_text()
ggeasy::easy_remove_axes_text()

ggeasy::easy_remove_x_axis_line()
ggeasy::easy_remove_y_title()
ggeasy::easy_remove_axes_title()

ggeasy::easy_remove_x_axis_line()
ggeasy::easy_remove_y_line()
ggeasy::easy_remove_axes_line()

ggeasy::easy_remove_x_axis_ticks()
ggeasy::easy_remove_y_ticks()
ggeasy::easy_remove_axes_ticks()

ggeasy::easy_remove_x_axis_line_ticks()
ggeasy::easy_remove_y_line_ticks()
ggeasy::easy_remove_axes_line_ticks()

API function naming ideas/thoughts rabbit-hole

I noticed that some function names start with easy_, then a verb and then the element thing: easy_change_text(). But then others start with easy, and omit a verb easy_text_color(). And then I went down a bit of a rabbit hole thinking about if starting afresh in naming, how might be most optimal with the benefit of hindsight.

To make it easiest for users to find what they want, consistent prefixes are easiest with auto complete and users brains. I think not having verbs first is easiest, as these are harder to guess (maybe except remove). I would drop the verb completely, as when it is change etc it is not required.

I think the easy prefix is a little long to type to get to the autocomplete, and might be unnecessary as if you type ggeasy:: you get the same effect. Most things users would be typing is x_, y_ or legend_, and then they would get the set of options available for this subset from auto complete.

So after first add the component thing:

  • text
  • title
  • subtitle
  • caption
  • x_title
  • x_labels
  • y_title
  • y_labels
  • legend_title
  • legend_labels
  • facet_labels
  • legend
    etc

Then add a suffix to get more specific: _blank, _size, _colour, angle, _position , _hjust etc

So:
x_title_size(size = NULL, recursive = TRUE, teach = FALSE)
legend_title_colour(colour = NULL, recursive = TRUE, teach = FALSE)
etc

Minor thing: use one variant of english consistently. You have colour and center used in your names. I'd vote for the British, as ggplot2 does this. So centre rather than center.

I'm not sure your willingness to break the API. Renaming is relatively easy from a coding point of view. I suppose it depends how much you value keeping past plots working vs making future plots easier. I tend towards the latter massively. So I think you should consider breaking stuff, if you think it will improve things.

Anyway, it's an awesome package. It is serving a super useful need. I've no doubt this package will get massive over time, as ggplot2 themes are so complex. So thanks for all the hard work on this!

... not passed to element_text()

... should be passed to element_text() in easy_rotate_*_labels() but it's orphaned at present.

If you're looking for a way to get your hands dirty, here's an easy bug to fix.

Easy theme adjustments

easy_font_size()
easy_font_colour()
easy_font() (a.k.a. family; may not actually be easy)

as well as anything else that requires theme(foo = element_bar(zap = "")) to work.

FYI, size, colour, etc... should be able to be added via easy_rotate_*_labels() if #18 is fixed.

Set origin to zero

Especially for bar charts, I often want to set the bottom of a plot to zero. This is now fairly easy thanks to tidyverse/ggplot2#1805

ggplot(mtcars) +
  geom_bar(aes(x = factor(cyl))) +
  scale_y_continuous(expand = c(0, 0, 0.1, 0))

For a chart where data doesn't automatically go to zero, you also need something like limits = c(0,NA)

I'm not exactly sure yet what the best form of a helper here is, will think and update, but wanted to get the ball rolling with issues for possible helpers.

Remove axes

Shortcut for

theme(axis.text.x = element_blank(),
           axis.title.x = element_blank(),
           axis.ticks.x = element_blank(), 
           axis.line.x = element_blank())

or same for y.

This could either be two separate functions, easy_remove_x_axis and easy_remove_y_axis, or one function easy_remove_axis with an argument that takes in either "x","y" or "both"

Legend to bottom

Is this "easy enough" already? That's my #2 Google query when I ggplot, #1 being "rotate x labels".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.