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

Added argument in show() to speficy figure number to use #799

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

fkgruber
Copy link

I added a feature allow to select the figure number to use to plot. This way you can work simultaneously with 2 different plot displayed in 2 different figure windows.

Example usage


import plotnine as pn
import pandas as pd

ggp1=(
     pn.ggplot(pd.DataFrame(
         {"x":[1,2,3,4,5],
          "y":[4,3,4,3,3]}),
               pn.aes("x","y")
               )
     +pn.geom_point()
    )
ggp1.show(1)



ggp2=(
    pn.ggplot(pd.DataFrame({"x":[1,2,3,4,5],
                            "y":[4,3,4,3,3]}),
              pn.aes("x","y"))
    +pn.geom_point(color="red")
)
ggp2.show(2)


(ggp1+pn.geom_line(color='blue')).show(1) 

@fkgruber
Copy link
Author

I push one more change to clear the figure when you provide a figure number.

@has2k1
Copy link
Owner

has2k1 commented Jun 24, 2024

Thanks for this feature. I am not yet sure about the internal API changes. The external
API p.show(num=1) is fine okay, but we should find a way not to add the parameter to 4 other internal functions i.e.

ggplot.draw(bool=False, num=None)
facet.setup(num=None)
facet.make_figure(num=None)
facet._make_figure(num=None)

I will find a way to get this in before the next release.

@has2k1
Copy link
Owner

has2k1 commented Aug 1, 2024

Out of precaution because the API may change, I will look to add reusing figures as part of v0.15.0 instead of v0.14.0 which is the next one. v0.15.0 will do more things around figures.

Other options to consider for this functionality are:

ggplot(figure_num=1)
from plotnine.options import set_option
set_option(figure_num=1)
...

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

Successfully merging this pull request may close these issues.

2 participants