It means if we are not using the show() function, it wouldn't show any plot. When we use the show() function in the non-interactive mode. That means when we write the code in the file it will show all the figures or plots and blocks until the plots have been closed.
The reason your plot is blank is that matplotlib didn't auto-adjust the axis according to the range of your patches. Usually, it will do the auto-adjust jobs with some main plot functions, such as plt. plot(), plt.
Just use
import matplotlib.pyplot as plt
plt.show()
This command tells the system to draw the plot in Pycharm.
Example:
plt.imshow(img.reshape((28, 28)))
plt.show()
I realize this is old but I figured I'd clear up a misconception for other travelers. Setting plt.pyplot.isinteractive()
to False
means that the plot will on be drawn on specific commands to draw (i.e. plt.pyplot.show()
). Setting plt.pyplot.isinteractive()
to True
means that every pyplot
(plt
) command will trigger a draw command (i.e. plt.pyplot.show()
). So what you were more than likely looking for is plt.pyplot.show()
at the end of your program to display the graph.
As a side note you can shorten these statements a bit by using the following import command import matplotlib.pyplot as plt
rather than matplotlib as plt
.
I had the same problem. Check wether plt.isinteractive()
is True. Setting it to 'False' helped for me.
plt.interactive(False)
I tried different solutions but what finally worked for me was plt.show(block=True)
. You need to add this command after the myDataFrame.plot()
command for this to take effect. If you have multiple plot just add the command at the end of your code. It will allow you to see every data you are plotting.
import matplotlib
matplotlib.use('TkAgg')
Works for me. (PyCharm/OSX)
I test in my version of Pycharm (Community Edition 2017.2.2), you may need to announce both plt.interactive(False) and plt.show(block=True) as following:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 6.28, 100)
plt.plot(x, x**0.5, label='square root')
plt.plot(x, np.sin(x), label='sinc')
plt.xlabel('x label')
plt.ylabel('y label')
plt.title("test plot")
plt.legend()
plt.show(block=True)
plt.interactive(False)
I have found a solution. This worked for me:
import numpy as np
import matplotlib.pyplot as plt
points = np.arange(-5, 5, 0.01)
dx, dy = np.meshgrid(points, points)
z = (np.sin(dx)+np.sin(dy))
plt.imshow(z)
plt.colorbar()
plt.title('plot for sin(x)+sin(y)')
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With