简体   繁体   中英

python matplotlib how to show labels

I have spent a few hours browsing various tutorials, so I am asking after trying for a bit. I am also unable to get a simple arrow on the offset X and Y axes...

from mpl_toolkits.axes_grid.axislines import SubplotZero
from matplotlib import pylab
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rcParams
rcParams.update({'figure.autolayout': True})

ax = plt.subplot(111)

sigma = [-4, -2, 0]
jomega = [0, 0, 0]
plt.plot(sigma, jomega, 'x', mew=2, ms=12, linestyle='None')

plt.xlabel("amaranthus")
plt.ylabel('j$\omega')
plt.xlim(-8,2)
plt.ylim(-8,8)

ax.spines['right'].set_color('none')
ax.spines['left'].set_position(('data',0))
ax.spines['top'].set_color('none')
ax.spines['bottom'].set_position(('data',0))

plt.show()

Thanks all for your help.

I was unable to get the X and Y axis labels with the above code.

When I moved the label code towards the end of the program, just before plt.show(), they magically appeared.

For the moment, I am good, unless of course some of you can throw some immediate light on why this happens for the benefit of others...

Best, Rajesh.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM