Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature: convert ggplot to plotly by adding a layer #1599

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

Open
atusy wants to merge 4 commits into plotly:master
base: master
Choose a base branch
Loading
from atusy:feature/gginteractive

Conversation

Copy link

@atusy atusy commented Aug 15, 2019

By this PR, we can convert ggplot to plotly by implementing gginteractive().
In addition, gginteractive has the interactive argument to control the conversion.

ggplot(mtcars, aes(wt, mpg)) +
 geom_point() +
 gginteractive()
 # gginteractive(FALSE) # can suppress conversion

This is a sort of syntax sugar for ggplotly(), which has to wrap whole ggplot:

ggplotly(
 ggplot(mtcars, aes(wt, mpg)) +
 geom_point()
)

MLopez-Ibanez reacted with thumbs up emoji
Copy link
Collaborator

Interesting, thanks! Is there a way we could do this without introducing a new function? That is, could something like this work?

ggplot(mtcars, aes(wt, mpg)) +
 geom_point() +
 ggplotly()

Copy link
Author

atusy commented Sep 4, 2019
edited
Loading

Well, I wanted to do so.
I did not do it because the first argument of ggplotly is last_plot().
If it is missing or NULL, we can do what we want by

if (missing(p)) return(ggintearactive())
# or
if (is.nuill(p)) return(gginteractive())

The only way is to add a new argument like

ggplotly <- function(..., layer = FALSE) {
 if (layer) return(gginteractive())
 ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /