0

similar questions have been asked before but the answers given couldn't solve my problem - at least I don't know how they could.

When running

import matplotlib.pyplot as plt

def main():
   plt.plot([1,2,3],[2,4,6])
   plt.show()

no image is shown and the program exists without error, regardles of whether I run the script under Geany or from the shell; I also ran the script from the shell with the verbose option but I couldn't make anything of the output: there is a lot imported and a lot of cleaning up done.

In the matplotlibrc file the backend TkAgg is set. I use: OpenSuse 13.2, python 2.7.12, matplotlib 1.5.1, matplotlib-tk 1.5.1, tk and tk-devel 8.6.3, TkInter 2.7.12

Matplotlib was installed with YAST. I don't know if it is important but when I printed

rcsetup.all_backends

the strings in the list were preceded by the letter u.

I am sure there is a simple solution and I would be grateful for any hint. If there is some vital information missing I will do my best to find it. A couple of weeks ago it worked but I don't know what has changed.

Many thanks in advance!

user157753
  • 11
  • 1

1 Answers1

0

You should call your main somehow, otherwise your matplotlib code is not being executed, try this:

test.py

import matplotlib.pyplot as plt

def main():
   plt.plot([1,2,3],[2,4,6])
   plt.show()

main()

And when you run # python test.py you'll get this output

enter image description here

BPL
  • 9,632
  • 9
  • 59
  • 117
  • Many thanks, BPL, that solved my problem. I wasn't using python for a while so this could be a reason why I have overlooked this important little detail. Since I had some time ago a problem regarding the backend which caused the same symptoms, I haven't considered anything like in the link from MattDMo. Many thanks! – user157753 Sep 05 '16 at 06:10