1 import
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
2 Data
X = np.arange(0, 12.1, 0.1)
Y = np.sin(X)
3 Plot
plt.plot(X, Y, 'r')
[]
plt.plot(X, Y, '--')
[]
plt.plot(X, Y, 'r:')
[]
plt.plot(X, Y, 'r-.')
[]
plt.plot(X, Y, color='lime', linestyle='-.')
[]
''' color 线颜色, linestyle 线性状, linewidth 线粗细, marker 标志性状,
markerfacecolor 标志颜色, markeredgecolor 标志边缘颜色, markersize 标志大小,
markerdegewidth 标志边缘大小
'''
plt.plot(X, Y, color='lime', linestyle='-', linewidth=2, \
marker='v', markerfacecolor='black', markeredgecolor='red',\
markersize=3, markeredgewidth=1)
[]
plt.scatter(X, Y)
fig = plt.figure(figsize=(8, 4))
plt.plot(X, Y, color='lime', linestyle='-', linewidth=2, \
marker='v', markerfacecolor='black', markeredgecolor='red',\
markersize=3, markeredgewidth=1, label='Normal case', zorder=2)
ax1 = plt.gca()
ax1.set_title('Big Title', fontname='Arial', fontsize=20, weight='bold', style='italic')
ax1.set_xlabel('time (UTC)')
ax1.set_ylabel('T($^o$C)')
ax1.set_xticks([0, 2.5, 7, 11])
ax1.set_xticklabels(['J', 'A', 'N', 'E'])
ax1.tick_params(axis='both', direction='in', color='blue', \
length=10, width=3)
plt.plot(X+2, Y, linewidth=3, label='Strange', zorder=1)
plt.legend(loc='best')
plt.tight_layout()
plt.savefig('./Big Title.png', dpi=400)
fig, ax = plt.subplots(3, 1)
ax[1].plot(X, Y)
ax[0].plot(X, Y, 'r')
ax[0].set_xlim([0, 10])
ax[2].set_xlim([0, 10])
ax[2].set_yscale('log')
ax2 = ax[2].twinx()
ax2.plot(X, Y, 'ro')
ax3 = ax2.twiny()
ax3.plot(X, Y, 'ro')
[]