【发布时间】:2020-07-28 00:35:21
【问题描述】:
我有一个子图脚本,我添加了子图文本和箭头(脚本结尾)。如何添加散点图?我试过了:
scatter = fig.add_scatter(0.5, 0.5, marker = '_', s=300)
fig.add_scatter(0.5, 0.5, marker = '_', s=300)
错误是: 'Figure' 对象没有属性 'add_scatter'
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D # 3d graph
from mpl_toolkits.mplot3d import proj3d # 3d graph
from matplotlib.text import Text
from matplotlib.patches import Arrow
# Plot subplot
fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 2, figsize=(10,13))
x = [0, 1]
y = [0, 5]
fig1 = plt.subplot(421)
plt.plot(x,y)
fig2 = plt.subplot(422)
plt.plot(x,y)
fig3 = plt.subplot(423, projection = '3d') # number of vertical figures, number of horizontal figures, order
# Plot figure with size
fig4=plt.subplot(424, projection = '3d')
fig5=plt.subplot(425, projection = '3d')
fig6=plt.subplot(426, projection = '3d')
fig7=plt.subplot(427, projection = '3d')
fig8=plt.subplot(428, projection = '3d')
text = fig.add_artist(Text(0.56,0.198, text='Hello'))
arrow = fig.add_artist(Arrow(0.52, 0.6, 0, -0.08, width=.02))
plt.show()
期望的结果是添加散点图,例如,在第 3 和第 4 个子图之间。
【问题讨论】:
标签: python-3.x matplotlib figure subplot