-
Notifications
You must be signed in to change notification settings - Fork 47
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
Incorrect 'plot_background' area (with empty space capture) #918
Milestone
Comments
from lets_plot import *
LetsPlot.setup_html()
margins = theme(plot_margin=40)
p = ggplot() \
+ geom_point(aes(x=[10, 20, 30], y=[0, 10, 20])) \
+ theme(plot_background=element_rect(size=6, fill='light_grey', color='black'))
gggrid([
p + ggtitle('Default'),
p + margins + ggtitle('plot_margin=40'),
p + margins + coord_fixed(0.5) + ggtitle('plot_margin=40 + coord_fixed()'),
p + margins + coord_fixed(0.5) + facet_grid(x='x') + ggtitle('plot_margin=40 + facet_grid')
]) |
Looks like background should be expanded by the margin. ggplot2 version for reference: df <- data.frame(
x = c(10, 10, 20, 20, 30, 30),
y = c(1, 10, 2, 8, 3, 5)
)
p = ggplot(df) +
geom_point(aes(x=x, y=y)) +
theme(
plot.margin=margin(2, 2, 2, 2, "cm"),
panel.background=element_rect(fill='orange'),
plot.background=element_rect(fill='grey')
) +
facet_grid(cols=vars(x)) +
ggtitle("Default")
p p + coord_fixed() + ggtitle("coord_fixed()") |
from lets_plot import *
LetsPlot.setup_html()
margins = theme(plot_margin=[5, 0, 0, 40])
p = ggplot() \
+ geom_point(aes(x=[0, 1, 2], y=[1, 2, 3])) \
+ theme(
plot_background=element_rect(size=5, fill='light_grey', color='grey'),
panel_background=element_rect(fill='orange'),
panel_grid_minor=element_line(),
)
dump_plot(gggrid([
p + ggtitle('Default'),
p + coord_fixed(0.3) + ggtitle('coord_fixed()'),
p + margins + ggtitle('plot_margin=[5, 0, 0, 40]'),
p + margins + coord_fixed(0.3) + ggtitle('plot_margin=[5, 0, 0, 40] + coord_fixed()'),
], ncol=2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The filled area corresponds to the overall size of the plot:
![Screenshot 2023-11-01 at 13 48 40](https://private-user-images.githubusercontent.com/46743085/279654716-5ec9abe8-1f53-4706-9ef7-4ab387b13cd9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0Mjg3MzIsIm5iZiI6MTcyMDQyODQzMiwicGF0aCI6Ii80Njc0MzA4NS8yNzk2NTQ3MTYtNWVjOWFiZTgtMWY1My00NzA2LTllZjctNGFiMzg3YjEzY2Q5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA4VDA4NDcxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFlNmNiYjQ3YzVkMTczNTVmZjdmYjFjNDgwZGE5MjhhZThmZTY2NDE2MGZkOTM3MzZhNzQ0ZGIxNTdiNzc1OTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ZDRxTv-BgnF3ecZPyTlIYoKB25cvVVBL-5cGDNVjYV0)
It's more correct not to take the empty space around - use the plotting area with all titles and margins.
![Screenshot 2023-11-01 at 13 48 25](https://private-user-images.githubusercontent.com/46743085/279654848-00cf9b32-e8f0-490a-bcd1-eb10a955e2e9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0Mjg3MzIsIm5iZiI6MTcyMDQyODQzMiwicGF0aCI6Ii80Njc0MzA4NS8yNzk2NTQ4NDgtMDBjZjliMzItZThmMC00OTBhLWJjZDEtZWIxMGE5NTVlMmU5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA4VDA4NDcxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThmNjg0YmFlZDhjN2NjM2MyNjg0MmZlOTM2MWIwMTc0YTM2NmI3ZWViYzkxODk4MTgyYzFhNGZmZGI0MWIwYWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.g7AZfj_2-rvJVBAvg62_tTd1dXWFXgY48CjE2OMTC2k)
The expected result will be like this:
The text was updated successfully, but these errors were encountered: