简体   繁体   English

matplotlib绘制3D轮廓标签

[英]matplotlib contours labels in 3D

Is there any way to put contours labels in 3D plots? 有什么方法可以在3D图中放置轮廓标签? Clabel is apparently not implemented in 3D Clabel显然未在3D中实现

import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

x,y = np.meshgrid(np.linspace(-1,1,10),np.linspace(-1,1,10))
z=-(x**2+y**2)

fig,ax = plt.subplots()
C=ax.contour(x,y,z)
ax.clabel(C)

fig = plt.figure()
ax = fig.add_subplot(111,projection='3d')
C=ax.contour(x,y,z,zdir='z',offset=-2)
ax.clabel(C)

在此处输入图片说明 在此处输入图片说明

As clabel is not implemented and the return value is None, there is indeed no point in calling clabel() for the time being. 由于未实现clabel且返回值为None,因此暂时没有必要调用clabel() You can use the C.levels attribute to manually add labels to the graph . 您可以使用C.levels属性将标签手动添加到图形

It won't have the nice inline feature that hides the contour under the labels though. 它不会具有将标签的轮廓隐藏在标签下的漂亮的inline功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM