-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
margin not working when there are multiple groups of series #623
Comments
There is no margin for the y axis, can you tell me what you are trying to achieve? |
I would like to apply |
By applying |
library(echarts4r)
plot <- mtcars |>
group_by(cyl) |>
e_charts(disp) |>
e_line(mpg) |>
e_y_axis_('mpg', margin = 12)
#Numbers are used as percentage of total plotting area. Created on 2024-04-10 with reprex v2.0.2 |
Thanks, can you explain how you came up 12 as the margin? I'm creating these plots in a Shiny app dynamically, so most likely I will need to be able to calculate the margins automatically. |
The reason I submitted an issue is I thought there was a solution from the way margin was applied to the series plotted to this problem, so it represents the true margin as indicated in the function: min = serie − margin and max = serie + margin |
Yeah, I see.. It conflist with the group by.. Here it works as intended.. library(echarts4r)
plot <- mtcars |>
e_charts(disp) |>
e_line(mpg) |>
e_y_axis_('mpg', margin = 0) I'm gonna look into it, but for now a simple workaround would be to do like this: library(echarts4r)
library(dplyr)
a <- mtcars |>
summarise(min = min(mpg), max = max(mpg))
plot <- mtcars |>
group_by(cyl) |>
e_charts(disp) |>
e_line(mpg) |>
e_y_axis( min = a$min, max = a$max )
plot
Created on 2024-04-16 with reprex v2.0.2 |
Thanks!! That's actually not a bad workaround at all. I have been doing something very similar anyways (calculating the margin by using min and max). |
Glad it helped ! Here is my buy me a coffee link if you feel like it |
Hi - I am trying to adjust
margin
ine_y_axis
so the plot can be centered around the actual visual (e.g. line), vs. having 0 as the minimum value of y as default. However, when the dataset isgroup_by
ed before plotting, seems like it only applies to one group of the series being plotted:SessionInfo():
R version 4.3.3 (2024-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
[7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
time zone: America/New_York
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] aws.s3_0.3.21 gtExtras_0.5.0 gt_0.10.1 reactable_0.4.4
[5] shinyWidgets_0.8.1 bsicons_0.1.2 glue_1.7.0 echarts4r_0.4.5
[9] bslib_0.6.1 shiny_1.8.0 lubridate_1.9.3 forcats_1.0.0
[13] stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2 readr_2.1.5
[17] tidyr_1.3.1 tibble_3.2.1 ggplot2_3.4.4 tidyverse_2.0.0
[21] here_1.0.1
The text was updated successfully, but these errors were encountered: