Legend with vertical line in matplotlib
问题 I need to show a vertical line in a matplotlib legend for a specific reason. I am trying to make matplotlib understand that I want a vertical line with the lines.Line2D(x,y) but this is clearly not working. import matplotlib.pyplot as plt from matplotlib import lines fig, ax = plt.subplots() ax.plot([0,0],[0,3]) lgd = [] lgd.append(lines.Line2D([0,0],[0,1], color = 'blue', label = 'Vertical line')) plt.legend(handles = lgd) I need the line to appear vertical, not the legend. Can anyone help?