I am trying to make a pie chart in python and i keep getting this traceback. Here is my code
#!/usr/bin/python
import sys
import re
import matplotlib.pyplot as plt
file1 = open(sys.argv[1])
file2 = open(sys.argv[2])
file3 = open(sys.argv[3])
all = []
count_1 = 0
count_2 = 0
count_3 = 0
for line in file1:
line = line.strip()
if line.startswith(">"):
count_1 += 1
all.append(count_1)
for line in file2:
line = line.strip()
if line.startswith(">"):
if re.search("CAGE_PLUS", line):
count_2 += 1
all.append(count_2)
for line in file3:
line = line.strip()
if line.startswith(">"):
if re.search("known", line):
count_3 += 1
all.append(count_3)
labels = ["All lincRNA", "CAGE lincRNA", "Known lincRNA"]
sizes = all
colors = ['yellowgreen', 'mediumpurple', 'lightskyblue']
plt.pie(sizes, # data
labels=labels, # slice labels
colors=colors, # array of colours
autopct='%1.1f%%' # print the values inside the wedges
)
plt.axis('equal')
plt.savefig('lincRNA_piechart')
This is how i am running it
python /evolinc_docker/lincRNA_fig.py All.lincRNAs.fa lincRNAs.with.CAGE.support.annotated.fa lincRNAs.overlapping.known.lincs.fa
And the traceback i'm getting is
Traceback (most recent call last):
File "/evolinc_docker/lincRNA_fig.py", line 50, in <module>
plt.pie(sizes, labels=labels, colors=colors)
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2959, in pie
ax = gca()
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 803, in gca
ax = gcf().gca(**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 450, in gcf
return figure()
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in figure
**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 79, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 87, in new_figure_manager_given_figure
window = Tk.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable