- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想使用 matplotlib 绘制 n 个单位根,每个单位根作为不同颜色的箭头。
它应该看起来像一个星形,箭头等距地指向外在单位圆上。
matplotlib 有一个绘制箭头的函数,但是有什么方法可以使用复数来绘制箭头,还是我必须转换为真正的笛卡尔坐标?
此外,是否存在一组库存颜色,以便无论我希望显示多少个根,它都会给我一组不同的颜色? (而不是说七个几乎相同的红色阴影)
最佳答案
import numpy as np
import pylab as plt
import itertools
n = 13
roots = np.roots( [1,] + [0,]*(n-1) + [-1,] )
colors = itertools.cycle(['r', 'g', 'b', 'y'])
plt.figure(figsize=(6,6))
for root in roots:
plt.arrow(0,0,root.real,root.imag,ec=colors.next())
plt.xlim(-1.5,1.5)
plt.ylim(-1.5,1.5)
plt.show()
单位根的计算方式类似于 this answer .
更新:如果你想使用seaborn
,你可以很容易地获得独特的颜色:
import numpy as np
import pylab as plt
import itertools
import seaborn as sns
n = 13
colors = sns.color_palette("hls", n)
roots = np.roots( [1,] + [0,]*(n-1) + [-1,] )
# Sorted by angle
idx = np.argsort([np.angle(x) for x in roots])
roots = roots[idx]
plt.figure(figsize=(6,6))
for root,c in zip(roots,colors):
plt.arrow(0,0,root.real,root.imag,ec=c,lw=3)
plt.xlim(-1.25,1.25)
plt.ylim(-1.25,1.25)
plt.show()
关于python - 将复数单位根绘制为复平面上的箭头向量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23299542/
我有一个包含两列的文件,第一列包含纯实数,第二列包含 GNUPLOT 可接受的形式的复数,{a,b}(GNUPLOT 等同于 a + bi)。我想用第二列的绝对值绘制第一列,所以我尝试了这个: 使用
我正在使用 pandas,它可以非常有效地按照我需要的方式对数据进行排序/过滤。 此代码运行良好,直到我将最后一列更改为复数;现在我得到一个错误。 return self._cython_agg_ge
我如何让 Django 意识到 countries 的单数形式是 country 而不是 countrie 最佳答案 来自docs ,如果你有一个名为 num_countries 的模板变量,你可以这
我正在从事一个项目,该项目要求我获取输入、执行 DFT(离散傅立叶变换),然后从这些值中获取过零次数。 我编写了一个算法,但它使用复数,我不知道如何操作/执行计算。这是代码: #include #i
我如何在 C 中动态定义复数的三维数组,以便我可以在访问数组时方便的 [i] [j] [k] 符号中访问? 最佳答案 扩展 Bob__ 的 example将数组分配到堆上而不是堆栈上: #includ
我想在我的 Android 项目中使用复数形式。但是,我提供的值可以是浮点值。 例如,当设置 1.5 星时,我希望这个理解,它不是 1 星而是 1.5 星s。 %d star %d star
问题:这是我的虚数正则表达式: [0-9]{0,}\d\.[0-9]{0,}\d[i]|[0-9]{0,}\d[i] 它只取一个纯复数部分的虚数。 当我的解析器遇到例如String im = "2i"
我知道关键,现在我需要搜索 5000 多个用户数据库时产生的所有 结果。任何用户可能没有一个或多个位置,由 id 和 name 字段标识。因此,我需要一个数组中的结果,不仅仅是第一个/最后一个,而是所
Gidday cobbers/尊敬的同事们, 通过实现卡尔曼预测/校正的多目标跟踪,我在其他 SO 线程中看到建议的一般方法是简单地为每个目标提供一个卡尔曼滤波器 vector/数组。 即'多单目标卡
尽管在 C# naming convention for enum and matching property 上阅读了类似但不完全是我想要的内容,但我还是在问这个问题 我发现我倾向于以复数命名枚举,
我正在尝试使用 getQuantityString基于 Android 开发人员指南检索数量字符串(复数)的资源中的方法 Quantity string (plurals) 我得到的错误是 Error
我想用 C++ 处理复数。因此我包括了#include .现在我的问题是:我如何声明一个变量?(那么我们说的格式是什么:1 + i?) 提前致谢:-) 最佳答案 // 1 + 2i std::com
我有一个名为 agency_persons 的表,其中已有一些数据。我使用 php artisan 创建了一个模型: php artisan make:model AgencyPerson 现在,当我
在 C++ 中,复数 double 的一维数组的最大大小是多少(即 std::complex array[dimension] )? 如果我在 main 和 global 中声明数组,最大大小是否有区
我使用 Mustache 来模板化我的 javascript ajax 调用,这是我的数据和模板: {'joined':1} // ajax responde data json. var myTem
我有这么大的问题。我写了一个关于复数的程序。该程序读取和写入复数,将它们相加等。 他说我应该读一下 Why should I overload a C++ operator as a global f
我将在 java 中重复我必须做的事情,以我认为我需要思考的方式来完成这个任务。 (抱歉,我是编程新手)。 头等舱;为复数定义类。我发现这很容易,我的答案如下。 public class Comple
如何在新的 dev django 版本的管理站点上将某些模型名称从“Categorys”更改为“Categories”?在旧版本中(没有管理站点和管理模型)你可以这样做; http://www.the
我最近才发现一种通过 this video 生成毕达哥拉斯三元组的方法解释它,涉及使用高斯(复杂)整数。到目前为止,我已经设法编写了一个函数,该函数返回由每个高斯整数生成的勾股三元组列表,其中虚部小于
我决定尝试一下 complex.h,然后遇到了一个我认为非常奇怪的问题。 int mandelbrot(long double complex c, int lim) { long doubl
我是一名优秀的程序员,十分优秀!