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

FigureCanvasQTCairo #31

Open
andersonbrito opened this issue Mar 19, 2020 · 4 comments
Open

FigureCanvasQTCairo #31

andersonbrito opened this issue Mar 19, 2020 · 4 comments

Comments

@andersonbrito
Copy link

Hi,

Thank you for creating this useful resource.

I'm trying to run the example shown in "Reading the features from a GenBank or GFF file", using the code below:

from dna_features_viewer import BiopythonTranslator

annotation = BiopythonTranslator().translate_record("example.gb")
ax, _ = annotation.plot(figure_width=10, strand_in_label_threshold=7)

... but I'm getting this error. Could you point me to a solution? I couldn't find it among the existing 'Issues'. Thank you

    ax, _ = annotation.plot(figure_width=10, strand_in_label_threshold=7)
  File "/anaconda3/lib/python3.7/site-packages/dna_features_viewer/GraphicRecord/MatplotlibPlottableMixin.py", line 445, in plot
    renderer = ax.figure.canvas.get_renderer()
AttributeError: 'FigureCanvasQTCairo' object has no attribute 'get_renderer'

@Zulko
Copy link
Member

Zulko commented Mar 19, 2020

What is your matplotlib version?

import matplotlib
print (matplotlib.__version__)

@andersonbrito
Copy link
Author

I'm using the version 3.1.3

@Zulko
Copy link
Member

Zulko commented Mar 19, 2020

Hmmm, same version I have on my machine, and I don't get any error.

Try adding this at the top of your script:

import matplotlib
matplotlib.use('agg')

@andersonbrito
Copy link
Author

Thank you, @Zulko.

I tried now using matplotlib.use("Agg"), the error is gone. However, I've been only able to see the results as an exported PNG/PDF file.

from dna_features_viewer import BiopythonTranslator
ax, _ = annotation.plot()
annotation.plot_legend(ax=ax)
ax.figure.tight_layout()
ax.figure.savefig(path + "custom_bopython_translator.pdf")

Which command one can use to see the plot on XQuartz?
Is it possible with the Agg renderer?

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