Skip to content

Improve tinytheme("ipsum")? #409

@grantmcdermott

Description

@grantmcdermott

I was playing around with some code yesterday and realised that our "ipsum" theme implementation is actually quite far off the original. Compare:

library(ggplot2)
library(hrbrthemes)

ggplot(mtcars, aes(mpg, wt, col = factor(cyl))) +
  geom_point() +
  labs(x="Fuel efficiency (mpg)", y="Weight (tons)", 
       title="Seminal ggplot2 scatterplot example",
       subtitle="A plot that is only useful for demonstration purposes"#,
       # caption="Brought to you by the letter 'g'"
       ) + 
  theme_ipsum() +
  scale_colour_ipsum()

library(tinyplot)
tinytheme("ipsum")

plt(
  wt ~ mpg | factor(cyl), mtcars,
  xlab="Fuel efficiency (mpg)", ylab="Weight (tons)", 
  main="Seminal ggplot2 scatterplot example",
  sub="A plot that is only useful for demonstration purposes"
)

While our theme implementations are more in the spirit of "inspired by" than intended to be exact replicas, bringing them closer into alignment only requires a few tweaks:

tinytheme("ipsum", family = "Arial Narrow", font.main = 2, font.sub = 1,
          palette.qualitative = ipsum_pal()(9))

plt(
  wt ~ mpg | factor(cyl), mtcars,
  xlab="Fuel efficiency (mpg)", ylab="Weight (tons)", 
  main="Seminal ggplot2 scatterplot example",
  sub="A plot that is only useful for demonstration purposes"
)

Of the above changes, the following would be very straightforward to implement:

  • Change main and sub font families. (Optional, but also easy: Reduce size of axis titles and tick labels)
  • Use the same colors for palette.qualitative as ipsum_pal()(9)

Changing the default family to "Arial Narrow" is more complicated, since I'm not fully up to speed on precisely how wide the expected coverage is. (Maybe @hrbrmstr or @eddelbuettel could weigh in based on their experience?) But we could perhaps implement some internal logic that checks for an installed version of Arial Narrow first, before defaulting back to "sans".

P.S. Even if we changed tinytheme("ipsum") to closer match the original, I would still want to keep the current version. Maybe as tinytheme("ipsum2")?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions