Как добавить разброс к рисунку над сюжетами? - PullRequest
0 голосов
/ 15 апреля 2020

У меня есть сценарий для вспомогательных сюжетов, и я добавил текст для вспомогательного сюжета и стрелку (конец сценария). Как добавить скаттер? Я пробовал:

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()

enter image description here

Желаемым результатом является добавление разброса, например, между 3-м и 4-м подплотами.

1 Ответ

0 голосов
/ 15 апреля 2020

Возможно, вы не понимаете полное намерение вопроса, но вы можете нарисовать точечный график с помощью следующего кода.

N=100
X = np.random.rand(N, 3)
y = np.random.rand(N) * 2 - 1
fig3.scatter(X[:, 0], X[:, 1],zs=X[:, 2],zdir='z', s=50, c=y, cmap=plt.cm.jet)
...