The code is not working, but in the site "repl.it" it´s working,, nothing happens. the fig.show() should print a graphic chart.
import matplotlib.pyplot as plt
seq_human = {'AA': 116, 'AT': 95, 'AC': 97, 'AG': 113, 'TA': 85, 'TT': 113, 'TC': 109, 'TG': 111, 'CA': 87, 'CT': 105, 'CC': 184, 'CG': 170, 'GA': 134, 'GT': 105, 'GC': 155, 'GG': 184}
seq_bacteria = {'AA': 105, 'AT': 64, 'AC': 86, 'AG': 111, 'TA': 64, 'TT': 57, 'TC': 60, 'TG': 108, 'CA': 83, 'CT': 75, 'CC': 74, 'CG': 97, 'GA': 113, 'GT': 93, 'GC': 109, 'GG': 147}
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(16, 5))
ax1.bar(seq_human.keys(), seq_human.values(), width=0.4, align='edge', label='Human: 18S rRNA gene')
ax1.bar(seq_bacteria.keys(), seq_bacteria.values(), width=-0.4, align='edge', label='Bacteria: Escherichia coli 16S ribosomal')
ax1.set_ylabel('Frequency')
ax1.set_xlabel('Nitrogenous Bases')
ax1.legend()
fig.show()
From the doc string of fig.show
Warning:
This does not manage an GUI event loop. Consequently, the figure may only be shown briefly or not shown at all if you or your environment are not managing an event loop.
Proper use cases for
.Figure.show
include running this from a GUI application or an IPython shell.If you're running a pure python shell or executing a non-GUI python script, you should use
matplotlib.pyplot.show
instead , which takes care of managing the event loop for you.
emphasis is mine…
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.