Jupyter Notebook,在多个单元上构建图

时间:2019-05-18 17:09:38

标签: python matplotlib jupyter-notebook

我正在使用Jupyter Notebooks作为教学工具。我想在几个单元格上建立一个图,并为每个单元格添加新元素。它不必是相同的情节。我没有看到如何使用matplotlib“ plot”系列功能来执行此操作。这可能吗,有人可以举一个例子吗? 谢谢

我正在Mac上通过Anaconda运行笔记本电脑。

这里是一个在图中绘制单个线条的单元格(调用field_line函数实际进行计算。

def full_fl_3D(xfoot,yfoot,zfoot,c):
    fline = field_line(xfoot,yfoot,zfoot,-1.0) # calculate negative directed field line
    dipole = ax.plot(fline[0],fline[1],fline[2],c)
    fline = field_line(xfoot,yfoot,zfoot,1.0)  # calcualte positive directed field line
    dipole = ax.plot(fline[0],fline[1],fline[2],c)

此代码生成绘图。我将想对此做进一步的补充,而不必再次构建整个东西。

%matplotlib notebook
fig = plt.figure(figsize=(8,8))
ax = plt.axes(projection='3d')
ax.set_xlim(-rmax, rmax);ax.set_ylim(-rmax, rmax);ax.set_zlim(-rmax, rmax) #set plot limits
spos = sphere(1)
ax.plot_surface(spos[0], spos[1], spos[2], color='b',alpha = 0.1)
# plot field lines starting 
nmax = 4
for i in range(2,8,2):
    xfoot = float(i)
    # plot the day - night plane
    c="c"
    full_fl_3D(xfoot,0,0,c);full_fl_3D(-xfoot,0,0,c)
    # plot the dawn-dusk plane
    c="y"
    full_fl_3D(0,xfoot,0,c); full_fl_3D(0,-xfoot,0,c);

0 个答案:

没有答案