我一直在用seaborn在python中搜索3D图,但没有看到。我想三维绘图的数据集,我原来绘制使用海伯恩佩尔普洛特。有谁能帮我解决这两个问题吗:
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.,ncol=4)
操作时,我看到以下错误:anaconda2/lib/python2.7/site packages/matplotlib/axes/u axes.py:545:UserWarning:未找到标记的对象。在单个绘图上使用label='…'kwarg。warnings.warn(“找不到带标签的对象。”提前谢谢! 我的推荐信:How to make a 3D scatter plot in Python?https://pythonspot.com/3d-scatterplot/https://jakevdp.github.io/PythonDataScienceHandbook/04.12-three-dimensional-plotting.html
这是一个MWE:
import re, seaborn as sns, numpy as np, pandas as pd, random
from pylab import *
from matplotlib.pyplot import plot, show, draw, figure, cm
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
sns.set_style("whitegrid", {'axes.grid' : False})
fig = plt.figure(figsize=(6,6))
ax = Axes3D(fig) # Method 1
# ax = fig.add_subplot(111, projection='3d') # Method 2
x = np.random.uniform(1,20,size=20)
y = np.random.uniform(1,100,size=20)
z = np.random.uniform(1,100,size=20)
ax.scatter(x, y, z, c=x, marker='o')
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
plt.show()
#Seaborn pair plot
df_3d = pd.DataFrame()
df_3d['x'] = x
df_3d['y'] = y
df_3d['z'] = z
sns.pairplot(df_3d, hue='x')
目前没有回答
相关问题 更多 >
编程相关推荐