我有最初位于3列数据中的空间数据集-x,y,z
请运行以下代码,然后查看数据外观。
Sub CopyCell2()
Const rowvalue As Long = 7
Rows(rowvalue).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromRightOrBelow
Cells(rowvalue, 10).Offset(-1).Resize(2).Formula _
= Cells(rowvalue - 1, 10).Formula
End Sub
我想复制使用meshgrid生成的图形:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
data = pd.DataFrame(np.array([[50. , 50. , 0.3],
[55. , 25. , -1.5],
[ 6.6, 47.4, 0.1],
[35. , 34.9, 1. ],
[32.7, 56.3, 1.9]]), columns=['x', 'y', 'z'])
x = data['x']
y = data['y']
z = data['z']
def plot_sparse(x, y, z, ax, dist_max, **kwargs):
assert len(x) == len(y) == len(z), "x, y, and z must have the same dimension"
sc = ax.scatter(x, y, c=z, **kwargs)
ax.set_aspect("equal")
ax.set_xlim(0, dist_max)
ax.set_ylim(0, dist_max)
return sc
fig, ax = plt.subplots()
sc = plot_sparse(x, y, z, ax=ax, dist_max=80)
fig.colorbar(sc)
但是我不知道如何将z轴的值嵌入到网格中。上面使用meshgrid的代码在2D表面图上将没有颜色条,但是我想使用meshgrid数据类型制作颜色条。
我该怎么做?