Matplotlib绘制虚线圆圈(使用plt.plot而不是plt.scatter) [英] Matplotlib Plot Dashed Circles (using plt.plot instead of plt.scatter)

查看:1069
本文介绍了Matplotlib绘制虚线圆圈(使用plt.plot而不是plt.scatter)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出以下内容:

import matplotlib.pyplot as plt 
import numpy as np 
#http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.scatter
x = np.random.randn(60) 
y = np.random.randn(60)
x2 = np.random.randn(60)
y2 = np.random.randn(60)

plt.plot(x, y, marker='o', markeredgecolor='r', linestyle='none', markerfacecolor='none')
plt.plot(x2, y2, marker='o', markeredgecolor='r', linestyle='none', markerfacecolor='none')
plt.show()

我希望将x2和y2绘制为虚线(甚至是虚线)圆圈.我避免使用plt.scatter,因为脚本的其余部分可以更好地与plt.plot一起使用. 这是我在寻找的东西:

I'd like for x2 and y2 to be plotted as dashed (or even dotted) circles. I am avoiding the use of plt.scatter because the rest of my script works with plt.plot much better. Here's what I'm looking for:

提前谢谢!

仅供参考: 这是我创建的实际图表.我现在仅使用六边形来表示不同的数据(未来数据).

FYI: Here's the actual chart I created. I just used hexagons for now to signify the different data (future data).

自定义图例和在熊猫数据框中的行组上绘制增加了plt.scatter无法克服的复杂性层.

The custom legend and plotting over groups of rows in a pandas Data Frame add layers of complexity that I couldn't overcome with plt.scatter.

推荐答案

您可以使用STIX字体(pdf和所有符号

You can use the dotted circle (ur'$\u25CC$') from the STIX font (pdf with all symbols here) using mathtext functionality

 plt.plot(x, y, marker=ur'$\u25CC$', markerfacecolor='r', 
                markeredgecolor='r', markersize=30, linestyle='none', )

请注意,markerfacecolor也设置为一种颜色.

Note, that markerfacecolor is set to a color as well.

一个缺点是它们需要一定的大小才能与闭合的圆区分开.

A drawback is that they need a certain size to be distinguishable from a closed circle.

这篇关于Matplotlib绘制虚线圆圈(使用plt.plot而不是plt.scatter)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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