上QQ阅读APP看书,第一时间看更新
How to do it...
Working on non-interactive mode won't be difficult either:
- Start the kernel afresh, and import the matplotlib and pyplot libraries:
import matplotlib
import matplotlib.pyplot as plt
- Set the interactive mode to OFF:
plt.ioff()
- Check the status of interactive mode:
matplotlib.is_interactive()
- You should get the output False.
- Execute the following code; you will not see the plot on your screen:
# Plot a line graph
plt.plot([1.5, 3.0])
# Plot the title, X and Y axis labels
plt.title("Non Interactive Mode")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
- Execute the following statement, and then you will see the plot on your screen:
# Display the graph on the screen
plt.show()