NLTK Lexical Dispersion Plot does not show on Google Colab
The NLTK example code below runs just fine on my local system and shows the correct diagram (https://www.nltk.org/book/ch01.html#fig-inaugural):
import nltk
nltk.download('book')
from nltk.book import text4
import matplotlib
import matplotlib.pyplot
import numpy as np
text4.dispersion_plot(["citizens", "democracy", "freedom", "duties", "America"])
However, it does not show the diagram when running on Google Colab. The title and axes are displayed, size and dimensions look ok but the actual dispersion plots are invisible.
Other matplotlib.pyplot diagrams do show, also all my other notebooks run on Google Colab. I have no idea why this particular diagram does not show.
System is Ubuntu 18.04.1 LTS, browser is Firefox.
python nltk google-colaboratory
add a comment |
The NLTK example code below runs just fine on my local system and shows the correct diagram (https://www.nltk.org/book/ch01.html#fig-inaugural):
import nltk
nltk.download('book')
from nltk.book import text4
import matplotlib
import matplotlib.pyplot
import numpy as np
text4.dispersion_plot(["citizens", "democracy", "freedom", "duties", "America"])
However, it does not show the diagram when running on Google Colab. The title and axes are displayed, size and dimensions look ok but the actual dispersion plots are invisible.
Other matplotlib.pyplot diagrams do show, also all my other notebooks run on Google Colab. I have no idea why this particular diagram does not show.
System is Ubuntu 18.04.1 LTS, browser is Firefox.
python nltk google-colaboratory
add a comment |
The NLTK example code below runs just fine on my local system and shows the correct diagram (https://www.nltk.org/book/ch01.html#fig-inaugural):
import nltk
nltk.download('book')
from nltk.book import text4
import matplotlib
import matplotlib.pyplot
import numpy as np
text4.dispersion_plot(["citizens", "democracy", "freedom", "duties", "America"])
However, it does not show the diagram when running on Google Colab. The title and axes are displayed, size and dimensions look ok but the actual dispersion plots are invisible.
Other matplotlib.pyplot diagrams do show, also all my other notebooks run on Google Colab. I have no idea why this particular diagram does not show.
System is Ubuntu 18.04.1 LTS, browser is Firefox.
python nltk google-colaboratory
The NLTK example code below runs just fine on my local system and shows the correct diagram (https://www.nltk.org/book/ch01.html#fig-inaugural):
import nltk
nltk.download('book')
from nltk.book import text4
import matplotlib
import matplotlib.pyplot
import numpy as np
text4.dispersion_plot(["citizens", "democracy", "freedom", "duties", "America"])
However, it does not show the diagram when running on Google Colab. The title and axes are displayed, size and dimensions look ok but the actual dispersion plots are invisible.
Other matplotlib.pyplot diagrams do show, also all my other notebooks run on Google Colab. I have no idea why this particular diagram does not show.
System is Ubuntu 18.04.1 LTS, browser is Firefox.
python nltk google-colaboratory
python nltk google-colaboratory
asked Jan 19 at 6:10
nn4lnn4l
4321617
4321617
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
This bug might be related to matplotlib backend not using Tkgg or Colab's pylab library. Note that the figure is plotted using matplotlib.pylab (in NLTK's dispersion.py) and they've seemed to discourage the use of pylab. I've opened an issue here if you want to stay updated, meanwhile you can run the code from your local compiler, save the figure and use it in Colab if the output is something you need.
You may try to display the figure in an external window instead of inline using
%matplotlib qt, if you get a binding error try installing PyQt5 using !pip install PyQt5.
I've tried the methods above and it didn't seem to work for me, if the issue does get resolved or if you do find a solution, do post it here, please.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54264548%2fnltk-lexical-dispersion-plot-does-not-show-on-google-colab%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This bug might be related to matplotlib backend not using Tkgg or Colab's pylab library. Note that the figure is plotted using matplotlib.pylab (in NLTK's dispersion.py) and they've seemed to discourage the use of pylab. I've opened an issue here if you want to stay updated, meanwhile you can run the code from your local compiler, save the figure and use it in Colab if the output is something you need.
You may try to display the figure in an external window instead of inline using
%matplotlib qt, if you get a binding error try installing PyQt5 using !pip install PyQt5.
I've tried the methods above and it didn't seem to work for me, if the issue does get resolved or if you do find a solution, do post it here, please.
add a comment |
This bug might be related to matplotlib backend not using Tkgg or Colab's pylab library. Note that the figure is plotted using matplotlib.pylab (in NLTK's dispersion.py) and they've seemed to discourage the use of pylab. I've opened an issue here if you want to stay updated, meanwhile you can run the code from your local compiler, save the figure and use it in Colab if the output is something you need.
You may try to display the figure in an external window instead of inline using
%matplotlib qt, if you get a binding error try installing PyQt5 using !pip install PyQt5.
I've tried the methods above and it didn't seem to work for me, if the issue does get resolved or if you do find a solution, do post it here, please.
add a comment |
This bug might be related to matplotlib backend not using Tkgg or Colab's pylab library. Note that the figure is plotted using matplotlib.pylab (in NLTK's dispersion.py) and they've seemed to discourage the use of pylab. I've opened an issue here if you want to stay updated, meanwhile you can run the code from your local compiler, save the figure and use it in Colab if the output is something you need.
You may try to display the figure in an external window instead of inline using
%matplotlib qt, if you get a binding error try installing PyQt5 using !pip install PyQt5.
I've tried the methods above and it didn't seem to work for me, if the issue does get resolved or if you do find a solution, do post it here, please.
This bug might be related to matplotlib backend not using Tkgg or Colab's pylab library. Note that the figure is plotted using matplotlib.pylab (in NLTK's dispersion.py) and they've seemed to discourage the use of pylab. I've opened an issue here if you want to stay updated, meanwhile you can run the code from your local compiler, save the figure and use it in Colab if the output is something you need.
You may try to display the figure in an external window instead of inline using
%matplotlib qt, if you get a binding error try installing PyQt5 using !pip install PyQt5.
I've tried the methods above and it didn't seem to work for me, if the issue does get resolved or if you do find a solution, do post it here, please.
answered Jan 19 at 9:31
specbugspecbug
300310
300310
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54264548%2fnltk-lexical-dispersion-plot-does-not-show-on-google-colab%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown