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

tip_length in aes #30

Open
stanstrup opened this issue Aug 14, 2017 · 5 comments
Open

tip_length in aes #30

stanstrup opened this issue Aug 14, 2017 · 5 comments

Comments

@stanstrup
Copy link

Would it be possible to set the tip_length in the aes?

I am working on some time series data. So making a custom dataframe with the annotations could be nice.
Since I am comparing two different time series at same time/x it would be nicer to remove the tip and just have the p-value/annotation.

Here is an example (not time series though, just as an example for this specific problem):

annotation_df <- data.frame(color=c("E", "H"), 
                            start=c("Good", "Good"), 
                            end=c("Very Good", "Good"),
                            y=c(max(diamonds$carat), max(diamonds$carat)),
                            label=c("Comp. 1", "Comp. 2"),
                            tip_length = c(0.5,0))

annotation_df
#>   color start       end   y   label
#> 1     E  Good Very Good 3.6 Comp. 1
#> 2     H  Fair      Good 4.7 Comp. 2

ggplot(diamonds, aes(x=cut, y=carat)) +
  geom_boxplot() +
  geom_signif(data=annotation_df,
              aes(xmin=start, xmax=end, annotations=label, y_position=y, tip_length = tip_length),
              textsize = 3, vjust = -0.2,
              manual=TRUE) +
  facet_wrap(~ color) +
  ylim(NA, 5.3)

image

@const-ae
Copy link
Owner

Hey, thanks for the suggestion.

I have implemented the feature and it is available when you install from github:
devtools::install_github("const-ae/ggsignif")

  annotation_df <- data.frame(color=c("E", "H"),
                              start=c("Good", "Good"),
                              end=c("Very Good", "Good"),
                              y=c(max(diamonds$carat), max(diamonds$carat)),
                              label=c("Comp. 1", "Comp. 2"),
                              tip_length = c(0.2,0))

  annotation_df

  ggplot(diamonds, aes(x=cut, y=carat)) +
    geom_boxplot() +
    geom_signif(data=annotation_df,
                aes(xmin=start, xmax=end, annotations=label, y_position=y, tip_length = tip_length),
                textsize = 3, vjust = -0.2,
                manual=TRUE) +
    facet_wrap(~ color) +
    ylim(NA, 5.3)

image

@stanstrup
Copy link
Author

Thanks!

@stanstrup
Copy link
Author

This still leaves a small dot. Any way to get rid of that?

@const-ae
Copy link
Owner

Oh you are right...
I will see if I find a good solution, but I can't promise a quick solution, as I won't have time next week.

@IndrajeetPatil
Copy link
Collaborator

It's strange:
If I run the code interactively, I don't see the dot.
If I create a reprex in new R session, it reappears.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants