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

New theme arguments #87

Closed
ptoche opened this issue Feb 5, 2018 · 10 comments
Closed

New theme arguments #87

ptoche opened this issue Feb 5, 2018 · 10 comments

Comments

@ptoche
Copy link

ptoche commented Feb 5, 2018

The theme() function has a few new arguments, a couple of which may be worth adding to ggthemes. I'm thinking about plot.subtitle and plot.caption

Something for the to-do list perhaps...

@ptoche
Copy link
Author

ptoche commented Feb 5, 2018

I'm getting an error with theme_stata that I didn't get before:

Error in if (theme$panel.ontop) { : argument is of length zero

Is this panel.ontop a new argument? [EDIT: 2 months later, cannot reproduce the error]

Also (not sure if that's new), the theme economist gives an ugly horizontal line at the horizontal axis with overlapping labels for:

ggplot(mtcars, aes(x = cyl)) + geom_bar()

Also, for the economist theme, axis.text.y = element_text(hjust = 1,... works better for numbers along the vertical axis, while axis.text.y = element_text(hjust = 0,... works well for strings. I have checked that indeed that is how The Economist does it. This suggests setting hjust with a conditional on whether the labels are numeric or character/factor...

Quickly tested the following: "theme_base", "theme_calc", "theme_economist", "theme_excel", "theme_few", "theme_fivethirtyeight", "theme_gdocs", "theme_hc", "theme_par", "theme_pander", "theme_solarized", "theme_stata", "theme_tufte", "theme_wsj"

@jrnold
Copy link
Owner

jrnold commented Apr 3, 2018

I can't reproduce the error: error in if (theme$panel.ontop) { : argument is of length zero. Can you provide more info?

@jrnold
Copy link
Owner

jrnold commented Apr 3, 2018

Since the theme is independent of the data, it would be hard to directly include that condition. I could maybe add an arg that would set hjust to 0 or 1; it wouldn't be that much more convenient than manually setting it with theme, but would act like documentation as much as anything.

@jrnold
Copy link
Owner

jrnold commented Apr 3, 2018

I don't have any real plans for adding those new args for themes in the near future. If you find the settings that work well for a particular theme, I'd love a pull request.

@jrnold
Copy link
Owner

jrnold commented Apr 3, 2018

Also (not sure if that's new), the theme economist gives an ugly horizontal line at the horizontal axis with overlapping labels for:

I'm not sure what you're referring to here. The horizontal line is part of the theme; probably not the best for a bar chart, but that's what additional customization can be used for.

@ptoche
Copy link
Author

ptoche commented Apr 3, 2018

The Economist's theme with the "ugly" (quote) horizontal bar was the result of setting axis.text.x to NULL, which obviously wasn't a smart thing to do (I seem to remember setting axis.text.x to NULL as a workaround of some sort, perhaps no longer needed in recent versions of ggplot2):

ggplot(mtcars, aes(x = cyl)) + geom_bar() + theme_economist() + theme(axis.text.x = NULL)

rplot

@ptoche
Copy link
Author

ptoche commented Apr 3, 2018

Further info about the hjust comment:

ggplot(data = mtcars[c(1:8),], aes(x = mpg, y = row.names(mtcars)[1:8])) + geom_point() + 
    theme_economist() + theme(axis.text.y = element_text(hjust = 1))

rplot01

versus

ggplot(data = mtcars[c(1:8),], aes(x = mpg, y = row.names(mtcars)[1:8])) + geom_point() + 
    theme_economist() + theme(axis.text.y = element_text(hjust = 0))

rplot02

@ptoche
Copy link
Author

ptoche commented Apr 3, 2018

Another comment in passing, the Stata theme doesn't work well with long labels on the y-axis. Stata provides the angle(h) option to set the labels to horizontal, which can be obtained with theme(axis.text.y = element_text(angle = 0)). Perhaps a one-liner you can add to the readme file. Just a thought.

@ptoche ptoche closed this as completed Apr 3, 2018
@jrnold
Copy link
Owner

jrnold commented Apr 3, 2018

Those examples seem to be cases where the user has to do some additional formatting to polish the plot using the theme function. That's the case in many plots. I don't see anything about these particular examples that's much different than the typical workflow with plots.

@ptoche
Copy link
Author

ptoche commented Apr 3, 2018

You're right, so I closed the issue.

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

No branches or pull requests

2 participants