2

At first, I wrote

## show the map and all that ##
def showMap():
    plt.figure()
    plt.imshow(im)
    # draw junctions as squares
    plt.scatter(junctionX, junctionY, marker='s', color='green')
    plt.show()

Then, the interactive console hangs until I close the figure. This question gives a solution for this, and I modified my code to

## show the map and all that ##
def showMap():
    plt.figure()
    plt.imshow(im)
    # draw junctions as squares
    plt.scatter(junctionX, junctionY, marker='s', color='green')
    plt.ion()
    plt.show()

Now, indeed I can return to the console and keep running other codes, but my figure there becomes Non Responding. How may I fix it?


I am using the Python Tools for Visual Studio, because my project is a mix of a C++ project and a Python one. I have tested exactly the same code in Spyder, and it works perfectly fine there. So I think it is from the differences between IDEs.

Community
  • 1
  • 1
Sibbs Gambling
  • 19,274
  • 42
  • 103
  • 174
  • How are you running this code? – tacaswell Oct 08 '13 at 04:43
  • What do you mean that the figure "becomes non responding"? Windows wants you to close the window? Also, what are you trying to do? If you want to just keep a matplotlib window open while you make another plot, then perhaps you can just just plt.show() and run each script in a new python interpreter (this is the default using IDLE, and I think there is a setting for it in Spyder somewhere). Alternatively, you can make multiple figures in matplotlib using "plt.figure()". – DanHickstein Oct 08 '13 at 04:44
  • @tcaswell I sent the function snippet to interactive console. And then showMap(). – Sibbs Gambling Oct 08 '13 at 04:45
  • what shell are you using? I would suggest using `ipython` as that is what the interactive code was designed to work with. I suspect the problem you have is that you don't have the correct thread-magic set up in the background. (your using tk?) – tacaswell Oct 08 '13 at 04:47
  • @DanHickstein By "becomes non responding", I mean the window hangs there unclickable, once you move the mouse on it, the mouse becomes a loading circle, just like any normal program while hanging. I need to see the plot changes as I update it in the interactive console. Since now it hangs, I won't see it updates – Sibbs Gambling Oct 08 '13 at 04:47
  • @tcaswell Please see the updates in teh question – Sibbs Gambling Oct 08 '13 at 04:50
  • I know basically nothing about MS products, good luck! Please add tags to make sure MS/visual studio types see this question. – tacaswell Oct 08 '13 at 04:51
  • @tcaswell Thanks, but this actually has nothing to do with the MS VS, it is only a matter of a Python IDE – Sibbs Gambling Oct 08 '13 at 04:56
  • Unless I greatly miss-understood you, you are using an IDE embedded in/built on top of VS -> a MS VS problem. You have to figure out how to replicate the threading magic/gui main loop work that is taken care of for you in ipython. – tacaswell Oct 08 '13 at 05:00
  • But this code works when you use Spyder, right? Apparently Visual Studio hates interactive mode, but there might be some work around, some discussion here: http://pytools.codeplex.com/workitem/1207 You could always just create lots of figures and then use plt.show() at the end to display them all (assuming that's your goal...). – DanHickstein Oct 08 '13 at 05:01
  • @DanHickstein I don't even expect to see the figure gets updates now. At least it cannot just die like that. *You could always just create lots of figures and then use plt.show() at the end to display them all* this is exactly waht I am trying to do now. But it fails like this: http://i.imgur.com/4o41OBm.png?1 – Sibbs Gambling Oct 08 '13 at 05:06
  • @tcaswell it essentially is just the standard REPL without iPython. – Sibbs Gambling Oct 08 '13 at 05:08
  • But plotting just one figure works alright? That is weird. I think that actually Visual Studio has iPython. You might be able to switch it somewhere in the options: http://pytools.codeplex.com/discussions/451605 – DanHickstein Oct 08 '13 at 05:21

0 Answers0