我有一个pandas dataFrame,其中一列如下所示:
In [207]:df2.teams
Out[207]:
0 [SF, NYG]
1 [SF, NYG]
2 [SF, NYG]
3 [SF, NYG]
4 [SF, NYG]
5 [SF, NYG]
6 [SF, NYG]
7 [SF, NYG]
Run Code Online (Sandbox Code Playgroud)
我需要使用pandas将这列列表拆分为2列,名为team1和team2
我想将标题的一部分改为粗体.例如:
plt.title("This is title number: " + str(number))
Run Code Online (Sandbox Code Playgroud)
鉴于如上所述的标题,我将如何加粗该str(number)
部分.
我有一个 3 位数的情节。我想要两行图像,顶行有 2 个图,底部有 1 个图。我需要将第二行的单个图居中对齐。
fig, ax = plt.subplots(nrows=2, ncols=2)
x = np.arange(0.01,1.01,0.01)
y = np.arange(0.01,1.01,0.01)
X,Y = np.meshgrid(x, y) # grid of point
Z = 1/((1/X)+(1/Y)-1)
F = Y / X
values = [0.3, 0.5, 0.8, 1.0, 1.3, 1.5, 2.0, 3.0, 5.0, 10.0]
#Plot 0
ax[0,0].set_aspect('equal')
CS = ax[0,0].contour(X,Y,Z,np.arange(0.1,1.0,0.1),colors='black',linewidths=0.7)
ax[0,0].clabel(CS, fontsize=12, fmt='%1.1f', inline=1)
CS = ax[0,0].contour(X,Y,F,values,colors='blue', linewidths=0.7)
ax[0,0].clabel(CS, fontsize=12, fmt='%1.1f', inline=1)
#Plot 1
ax[0,1].set_aspect('equal')
CS = ax[0,1].contour(X,Y,Z,np.arange(0.1,1.0,0.1),colors='black',linewidths=0.7)
ax[0,1].clabel(CS, fontsize=12, fmt='%1.1f', inline=1)
CS = ax[0,1].contour(X,Y,F,values,colors='blue', linewidths=0.7)
ax[0,1].clabel(CS, fontsize=12, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 cron 运行 python 脚本。该脚本从命令行运行时没有问题,但从 cron 运行时,matplotlib 出现问题。错误如下。
回溯(最近一次调用最后一次):
文件“/home/ubuntu/python/spread.py”,第 154 行,在 plot_spread(lat, lon, vals, mean, maxs, mins, stdp, stdm, ens_members)
文件“/home/ubuntu/python/spread.py”,第 81 行,在 plot_spread plt.fill_between(x, maxs, stdp, color='r', alpha=0.2)
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/pyplot.py”,第2785行,在fill_between ax = gca()
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/pyplot.py”,第928行,gca返回gcf()。 gca(**kwargs)
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/pyplot.py”,第578行,gcf返回图()
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/pyplot.py”,第527行,图**kwargs)
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4agg.py”,第46行,new_figure_manager return new_figure_figurer数量,这个图)
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4agg.py”,第53行,在new_figure_manager_givenQfigureTA canvas = (数字)
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4agg.py”,第76行,在init FigureCanvasQT中。初始化(自我,数字)
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4.py”,第68行,在init _create_qApp()
文件“/usr/lib/python2.7/dist-packages/matplotlib-1.5.0_818.gfd83789-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt5.py”,第138行,在_create_qApp引发运行时错误( '无效的 DISPLAY 变量')
运行时错误:无效的 DISPLAY 变量