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

Horizontal alignment of figures #959

Closed
kendonB opened this issue Feb 23, 2015 · 2 comments
Closed

Horizontal alignment of figures #959

kendonB opened this issue Feb 23, 2015 · 2 comments
Milestone

Comments

@kendonB
Copy link

kendonB commented Feb 23, 2015

Hi, I would like to know if it's possible to adjust the horizontal alignment of figures in knitr beyond fig.align? I would like to be able to make the following plot align so that the gray graph panel is centered with the paragraphs. Thanks so much for any help.

\documentclass{article}
\usepackage[margin=1in]{geometry}
\begin{document}
\noindent Here is a paragraph. Here is a paragraph. Here is a paragraph.
Here is a paragraph. Here is a paragraph. Here is a paragraph.
Here is a paragraph. Here is a paragraph. Here is a paragraph.
Here is a paragraph...
<<echo=FALSE, fig.align='center', fig.height=6, fig.width=6>>=
library(ggplot2)
bp <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot()
bp    
@
\noindent Here is a paragraph. Here is a paragraph. Here is a paragraph.
Here is a paragraph. Here is a paragraph. Here is a paragraph.
Here is a paragraph. Here is a paragraph. Here is a paragraph.
Here is a paragraph...  
\end{document}
@yihui yihui added this to the v1.10 milestone Apr 12, 2015
@yihui
Copy link
Owner

yihui commented Apr 12, 2015

I'm afraid the best advice I could offer at the moment is to put the legend at the bottom or top of the graph: http://docs.ggplot2.org/current/theme.html (search for legend.position on the page) knitr does not allow arbitrary position of the plot directly, although you can always hack the plot hook (if you understand what this means...)

@yihui yihui closed this as completed Apr 12, 2015
@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants