3

I just wrote some test code to make a three-way Venn Diagram. There's no errors, but there's also no output. I have logged in using the -XC parameter, and if i type "xclock", the picture of the clock pops up. When I run this script, nothing pops up at all (so it's not just an empty picture, there's no picture at all).

This is the code:

import numpy
import scipy
import matplotlib
from matplotlib_venn import venn3
import pylab as plt
set1 = set([1,2,3,4,5])
set2 = set([1,4,5,6])
set3 = set([1,4,6,8,6,3])

vd = venn3([set1,set2,set3],set_labels=("Set1","Set2","Set3"))
plt.title("Venn diagram")
plt.show()

I also read that I should change my back-ends; I tried doing this, but none of them seem to work, either for ones like PS/PDF; those ones I just get the same as above, no picture, no output. For other ones, e.g. Cairo, I get errors; and then I tried to re-install Cairo, and I got even more errors. So I would like to rule out basic problems because I get into installing things.

I'm just wondering, is the above code right, can anyone else get it to run that's on a similar system to me (using python 2.7 on Linux parker 3.2.0-90-generic #128-Ubuntu SMP Fri Aug 14 21:43:58 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux) in a virtual env; if you can get it to run; what is your back-end so then I know what back end I can focus on trying to set up?

Thanks

tdube
  • 2,453
  • 2
  • 16
  • 25
Tom
  • 243
  • 5
  • 13
  • Your example code works fine for me so it is almost certainly a backend issue. Are you looking to save the figure, or view it in a window? – mfitzp Apr 06 '16 at 15:45
  • To answer your questions I can get it working with both the Qt backend and (with an edit) the Jupyter notebook. – mfitzp Apr 06 '16 at 15:47
  • You can check your current backend using `import matplotlib; matplotlib.get_backend()` might be useful to find out what the current default is. – mfitzp Apr 06 '16 at 15:50
  • What's probably happened is that matplotlib was built without an interactive backend, and only the `Agg` backend is installed. (This is the default on many linux distributions.) In that case, you'll be able to save the figure (e.g. `plt.savefig`), but you won't get an interactive plot. How did you install or build matplotlib? – Joe Kington Apr 06 '16 at 17:09

1 Answers1

1

Thank you for the advice all. @JoeKington, this worked perfectly:

import numpy
import scipy
import matplotlib
from matplotlib_venn import venn3
import pylab as plt
set1 = set([1,2,3,4,5])
set2 = set([1,4,5,6])
set3 = set([1,4,6,8,6,3])

vd = venn3([set1,set2,set3],set_labels=("Set1","Set2","Set3"))
plt.title("Venn diagram")
plt.savefig("output",format="pdf")
Tom
  • 243
  • 5
  • 13