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

Support pictures with custom functions #112

Open
fzumstein opened this issue Aug 21, 2024 · 0 comments
Open

Support pictures with custom functions #112

fzumstein opened this issue Aug 21, 2024 · 0 comments

Comments

@fzumstein
Copy link
Member

fzumstein commented Aug 21, 2024

Might be doable via trigger_script but requires:

  • Caller cell
  • Custom scripts to accept arguments

Classic UDF sample:

import pandas as pd
import matplotlib.pyplot as plt
import xlwings as xw
import seaborn as sns

@xw.func
@xw.arg('corr', pd.DataFrame)
def corr_plot(corr, caller):
    ax = sns.heatmap(corr, cmap='coolwarm', vmin=-1, vmax=1, linewidths=.5,
                     xticklabels=True, yticklabels=True)
    ax.tick_params(left=False, bottom=False)
    plt.yticks(rotation=0)
    plt.xticks(rotation=90)
    caller.sheet.pictures.add(ax.get_figure(),
                              top=caller.offset(row_offset=1).top,
                              left=caller.left,
                              name='CorrPlot',
                              update=True)
    return '<Corr Plot>'
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

No branches or pull requests

1 participant