Polar/Contour 绘图:如何在圆内绘制一些曲线?

Polar/Contour Plot: How to plot some curves inside a circle?

我必须绘制方程式:

Y_axis = cos(phi) * sqrt(1 - (arctan(r)) /r ) --- 蜘蛛图

此处:

r = R / a_H 
Y_axis = V_r - V_sys 

不同的曲线适用于:
Y_axis = [0.0, 0.2, 0.4, 0.6, 0.8]

需要的剧情是这样的:

我试过了:

# Imports
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0.01, 5., 100001)
ya = [0.0, 0.2, 0.4, 0.6, 0.8]
s = lambda x: np.cos(0.) * np.sqrt((1. - (1. / x) * np.arctan(x)))


plt.plot(x, s(x), 'b-', label=r'$\frac{V(R)}{V_{H}}$')
plt.show()

我不知道如何创建右图这样的图表?

非常感谢您的帮助。

相关链接:
https://plot.ly/python/polar-chart/

你可以试试这个来得到一个有点相似的情节(玩弄参数来修改以类似于想要的)。你需要的是 contour plot 因为你有一个双变量函数 y=f(x,phi).

import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-5., 5., 1001)
phi = np.linspace(-1., 1., 1001)
X, Phi = np.meshgrid(x, phi)
Y = np.cos(Phi) * np.sqrt((1. - (1. / X) * np.arctan(X)))
plt.contour(X, Phi, Y)
plt.show()

本题摘自:
作者:Sparke 和 Gallagher
书籍:宇宙中的星系第 2 版
课程:天体物理学

借鉴三地盘的思路,我是这样做的:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Author      : Bhishan Poudel; Physics PhD Student, Ohio University
# Date        : Feb 3, 2017
# Last update :
#

# Imports
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt


def myplot(alpha, color='k'):
    """plot spider diagram."""
    c = lambda R: 0.62 * alpha / R * (1. + R**2)**0.75
    s = lambda R: np.sqrt(1. - (0.62 * alpha / R)**2 * (1. + R**2) ** 1.5)

    R = np.linspace(-5., 5., 10001)
    x = [i * c(i) for i in R]
    x1 = [-1 * i * c(i) for i in R]
    y = [i * s(i) for i in R]

    label = r'$V_r - V_{sys} = $' + str(alpha) + r'$V_{max}sin(30)$'
    plt.plot(x, y, label=label, color=color)
    plt.plot(x1, y, label=None, color=color)
    plt.legend()


def main():
    """main fn."""
    alphas = [0.2, 0.4, 0.6, 0.8]
    colors = sns.cubehelix_palette(4, start=0.0)
    for i, alpha in enumerate(alphas):
        myplot(alpha, colors[i])

    # now show the plot
    plt.xlim([-5., 5.])
    plt.ylim([-10., 10.])
    plt.xlabel(r'$x = r/a \quad cos(\phi)$')
    plt.ylabel(r'$y = r/a \quad sin(\phi)$')
    plt.legend(frameon=False, loc=1)
    plt.title(r'Fig. Spider diagram for rotational curve for Plummer model')
    # plt.savefig('fig_5_19a.pdf', bbox_inches='tight')
    plt.show()


if __name__ == '__main__':
    main()

生成的图像是:

更新

The closest figure I got it:  
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Author      : Bhishan Poudel; Physics PhD Student, Ohio University
# Date        : Feb 3, 2017
# Last update :
#

# Imports
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt


def myplot(alpha):
    """plot spider diagram."""

    R = np.linspace(-5., 5., 1001)
    c = lambda R: 0.62 * alpha / R * (1. + R**2)**0.75
    s = lambda R: np.sqrt(1. - (0.62 * alpha / R)**2 * (1. + R**2) ** 1.5)

    x = [i * c(i) for i in R]
    x1 = [-1 * i * c(i) for i in R]
    y = [i * s(i) for i in R]

    plt.text(np.nanmax(x)+0.1, np.nanmax(y), alpha)

    plt.plot(x, y, 'k-')
    plt.plot(x1, y, 'k:')

    # add circle
    circle1=plt.Circle((0,0),5,color='k', fill=False, ls='--')
    plt.gcf().gca().add_artist(circle1)


def main():
    """main fn."""
    alphas = [0.2, 0.4, 0.6, 0.8]
    for i, alpha in enumerate(alphas):
        myplot(alpha)

    # now show the plot
    plt.xlim([-10., 10.])
    plt.ylim([-10., 10.])
    plt.legend(frameon=False)
    plt.grid(False)
    plt.axis('off')
    plt.savefig('hello.png')
    plt.show()


if __name__ == '__main__':
    main()