About
Running Python Script in (Scientific|Cell) Mode with IDEA Intellij
Intellij IDEA can using the scientific view:
- show plot and data
- run and debug cell
Prerequisite
- Anaconda to get the scientific module
- The matplotlib and numpy package
- Scientific mode
Script
import numpy as np
import matplotlib.pyplot as plt
#%% Built a scatterplot (and define the start of a cell)
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radii
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()
#%% Plot y versus x as lines (and defines the start of another cell)
X = np.linspace(-np.pi, np.pi, 256,endpoint=True)
C,S = np.cos(X), np.sin(X)
plt.plot(X, C, color="blue", linewidth=2.5, linestyle="-")
plt.plot(X, S, color="red", linewidth=2.5, linestyle="-")
plt.xlim(X.min()*1.1, X.max()*1.1)
plt.xticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi],
[r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$'])
plt.ylim(C.min()*1.1,C.max()*1.1)
plt.yticks([-1, 0, +1],
[r'$-1$', r'$0$', r'$+1$'])
plt.show()
Run
One cell
To start the console and run one block, you can use:
- the gutter
- or the keymap (Default to Ctrl+Enter)
Script
To start the console and run all block, you can it the Run arrow but the configuration must use the Python console
Output: