为什么海象运算符不将关键字参数传递figsize
给matplotlib.pyplot.figure
此代码?
#TODO: visualize whether the index is a valid x_value
fontsize=21
plt.figure(figsize:=(8,8))
plt.scatter(x_values_theory, y_values_theory, label='Theory')
plt.scatter(x_values_experimental, y_values_experimental, label='Experiment')
plt.xlabel('xlabel', fontsize=fontsize)
plt.ylabel('ylabel', fontsize=fontsize)
plt.legend(fontsize=fontsize)
plt.tick_params(labelsize=fontsize)
plt.show()
产量
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-55-94183c23eb8f> in <module>
1 #TODO: visualize whether the index == df.[time
2 fontsize=21
----> 3 plt.figure(figsize:=(8,8))
4 plt.scatter(x_values_theory, y_values_theory, label='Theory')
5 plt.scatter(x_values_experimental, y_values_experimental, label='Experiment')
/usr/local/lib/python3.8/site-packages/matplotlib/pyplot.py in figure(num, figsize, dpi, facecolor, edgecolor, frameon, FigureClass, clear, **kwargs)
649 num = allnums[inum]
650 else:
--> 651 num = int(num) # crude validation of num argument
652
653 figManager = _pylab_helpers.Gcf.get_fig_manager(num)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'tuple'