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

BUG: When using Multiple, title is not working for each figure. #23

Open
toshiakiasakura opened this issue Sep 3, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@toshiakiasakura
Copy link
Owner

Code which produces the error. Title is only shown in the last part of the figure.

dfM = df_5y_each.copy()
year = 2016
mosaic = [[1,2],
          [3,4],]
          #[5,6]]
with cplt.Multiple(figsize=(6,6),
              dpi=300,
              mosaic=mosaic,
              sharex=True,sharey=True
              ) as mul:
    for i,year in enumerate([2016, 2017, 2018, 2019]): #, 2020]):
        with mul.Single(index=i+1, 
                        title="Title",
                        xlabel=f"Total births", 
                        ylabel=f"Off-site deliveries", 
                        ) as p:
            total_col = ("total", year)
            offsite_col = ("offsite", year)
            p.ax.scatter(dfM[total_col], dfM[offsite_col], s=6)

            # Prediction
            dfM["count"] = 1
            exog =  pd.concat((dfM["count"], dfM[total_col]),axis=1)
            res = sm.OLS(dfM[offsite_col], exog).fit()
            pred_birth = [[1, 0],[1, dfM[total_col].max()]]
            pred_offsite = res.predict(pred_birth)
            p.ax.plot([0, dfM[total_col].max()], pred_offsite, ls="--")

            for city, x,y in zip(dfM.city, 
                                 dfM[total_col], 
                                 dfM[offsite_col],
                                 ):
                if y > 40 or x >20_000 or city == "茨城県":
                    p.ax.annotate(city, (x,y), fontsize=8)
@toshiakiasakura toshiakiasakura changed the title When using Multiple, title is not working for each figures. When using Multiple, title is not working for each figure. Sep 3, 2022
@toshiakiasakura toshiakiasakura added the bug Something isn't working label Sep 3, 2022
@toshiakiasakura
Copy link
Owner Author

If using p.ax.set_title, the bug is solved.

@toshiakiasakura toshiakiasakura changed the title When using Multiple, title is not working for each figure. BUG: When using Multiple, title is not working for each figure. Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant