matplotlib.patches.FancyArrow已使尾部变稀疏 [英] matplotlib.patches.FancyArrow has thinned out tail

查看:51
本文介绍了matplotlib.patches.FancyArrow已使尾部变稀疏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行此代码时:

plt.figure(figsize=(3,3))
plt.xlim(-3, 3); plt.ylim(-3,3); 
plt.arrow(0,0, 2, 2, head_length=1.4, head_width=1.8, width=1.4,
   alpha=0.2, length_includes_head=True, fc='r')

我得到以下输出:

但是我不希望尾巴缩小.在我的另一台计算机上,我没有这个问题.有人知道怎么解决吗?

However I don't want the tail to be shrunk. On my other computer I don't have this problem. Does anybody know how to solve it?

我的 matplotlib 版本是 2.0.0.

My matplotlib version is 2.0.0.

推荐答案

这似乎是箭头中的某种错误.您会期望有一个 tail_width 参数,该参数设置箭头(或其箭头的尾部)的宽度.但是,这不存在.

This seems to be some kind of bug in the arrow. You would expect there to be a tail_width argument which sets the width of the arrow (or its tail). This however does not exist.

作为一种解决方法,您可以使用需要手动添加到轴的 FancyArrowPatch . FancyArrowPatch 具有参数 arrowstyle ,您可以向其提供参数字符串.在此字符串中,可以正确识别"tail_width" .

As a workaround, you may use a FancyArrowPatch which you need to manually add to the axes. The FancyArrowPatch has an argument arrowstyle to which you can supply a string of arguments. Within this string "tail_width" is correctly recognized.

import matplotlib.pyplot as plt
import matplotlib.patches as patches

plt.figure(figsize=(3,3))
plt.xlim(-3, 3); plt.ylim(-3,3);

style="Simple,head_length=28,head_width=36,tail_width=20"
plt.gca().add_patch(
        patches.FancyArrowPatch((0,0), (2,2),arrowstyle=style,alpha=0.2,fc='r' ))

plt.show()

这篇关于matplotlib.patches.FancyArrow已使尾部变稀疏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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