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

How to apply adjustText in QT? #120

Open
hcji opened this issue Dec 28, 2021 · 1 comment
Open

How to apply adjustText in QT? #120

hcji opened this issue Dec 28, 2021 · 1 comment

Comments

@hcji
Copy link

hcji commented Dec 28, 2021

Hi, I m trying to apply adjustText in plot of my GUI program. Here is the code snippet my plot function. It do not run correctly as it runs in scripts. Instead, it shows a blank window out of the GUI. I do not know how to fix it. Can you help?

    self.fig = Figure(figsize=(width, height), dpi=dpi)
    self.fig.subplots_adjust(top=0.95,bottom=0.2,left=0.15,right=0.85)
    super(MakeFigure,self).__init__(self.fig) 
    self.axes = self.fig.add_subplot(111)
    self.axes.cla()
    scatterplot(data=pltdata, x="x", y="y", hue="G", palette='tab10', legend=False, alpha=0.7, edgecolor='none', marker='.', ax=self.axes)   
    '''
    markers = pltdata[pltdata['G'] == 'Hits']
    markers = markers.iloc[:min(len(markers), 10),:]
    texts = []
    for i in markers.index:
        x, y, s = markers.loc[i, 'x'], markers.loc[i, 'y'], markers.loc[i, 'l'].split(';')[0]
        texts.append(self.axes.text(x, y, s, fontsize=3))
    
    p = adjust_text(texts, force_points=0.2, force_text=0.2,
                expand_points=(1, 1), expand_text=(1, 1),
                arrowprops=dict(arrowstyle="-", color='black', lw=0.5), ax=self.axes)
    '''
    self.draw()
@oscargus
Copy link
Contributor

Does it work without adjust_text? Since adjust_text is just moving the texts around, that is crucial info here.

If the problem is that the texts move weirdly, I believe that you can call self.fig.draw_without_rendering() just before adjust_text which may help.

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

2 participants