python绘图中的一个错误

python绘图中的一个错误,python,matplotlib,figure,Python,Matplotlib,Figure,我使用python2.x。错误消息如下所示。有人知道怎么修吗 import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from sklearn.linear_model import LinearRegression a = np.zeros((1000,3)) fig=plt.figure() ax=fig.gca(projection='3d') line1,=a

我使用python2.x。错误消息如下所示。有人知道怎么修吗

import numpy as np
import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import Axes3D
from sklearn.linear_model import LinearRegression

a = np.zeros((1000,3))
fig=plt.figure()
ax=fig.gca(projection='3d')
line1,=ax.plot(a[:,0], a[:,1], a[:,2], 'k')
ax.set_xlabel('$x_1_t$');ax.set_ylabel('$x_1_t-tau$');ax.set_zlabel('$x_1_t-2tau$')
plt.title('hello')
plt.show()

问题在于标签中使用了双下标:

Traceback (most recent call last):
   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 83, in _draw
    self.figure.draw(renderer)
   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.py", line 1475, in draw
    renderer, self, artists, self.suppressComposite)
   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/image.py", line 141, in _draw_list_compositing_images
    a.draw(renderer)
   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 298, in draw
    ax.draw(renderer)
   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axis3d.py", line 306, in draw
    self.label.draw(renderer)
   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/text.py", line 706, in draw
    bbox, info, descent = textobj._get_layout(renderer)
   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/text.py", line 309, in _get_layout
    ismath=ismath)
   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 237, in get_text_width_height_descent
    self.mathtext_parser.parse(s, self.dpi, prop)
   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mathtext.py", line 3293, in parse
    box = self._parser.parse(s, font_output, fontsize, dpi)
   File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mathtext.py", line 2521, in parse
    six.text_type(err)]))
 ValueError: 
^ Double subscript (at char 0), (line:1, col:1)
如果您更改为仅使用单个下标,则应该可以使用(例如:


正如另一个答案所表明的,问题在于试图在轴标签中使用双下标。解决方案取决于您希望标签的外观

如果希望
1
t
都是下标,则可以使用:

$x_1t$
如果希望第一个下划线是实际的下划线,则可以使用

$x_{1t}$
$x_{1t}$
$x\_1_t$