matplotlib:添加圆到绘图 [英] matplotlib: add circle to plot

查看:157
本文介绍了matplotlib:添加圆到绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在matplotlib中添加一个小的实心圆或指向一个countour图?

How do I add a small filled circle or point to a countour plot in matplotlib?

推荐答案

以下是使用 pylab.Circle :

import numpy as np
import matplotlib.pyplot as plt

e = np.e
X, Y = np.meshgrid(np.linspace(0, 5, 100), np.linspace(0, 5, 100))
F = X ** Y
G = Y ** X

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
circ = plt.Circle((e, e), radius=0.07, color='g')
plt.contour(X, Y, (F - G), [0])
ax.add_patch(circ)
plt.show()

这是另一个示例(尽管不是等高线图),文档.

And here is another example (though not a contour plot) from the docs.

或者,您可以只使用plot:

import numpy as np
import matplotlib.pyplot as plt

e = np.e
X, Y = np.meshgrid(np.linspace(0, 5, 100), np.linspace(0, 5, 100))
F = X ** Y
G = Y ** X

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
plt.contour(X, Y, (F - G), [0])
plt.plot([e], [e], 'g.', markersize=20.0)
plt.show()

这篇关于matplotlib:添加圆到绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆