2017-02-15 2 views
2

Ich habe die Gleichungen plotten:Polar/Contour Plot: Wie zeichne ich einige Kurven innerhalb eines Kreises?

Y_axis = cos(phi) * sqrt(1 - (arctan(r)) /r) --- für Spinnendiagramm

hier:

r = R/a_H 
Y_axis = V_r - V_sys 

verschiedenen Kurven sind für:
Y_axis = [0.0, 0.2, 0.4, 0.6, 0.8]

Die erforderliche Grundstück ist dies :
enter image description here

Ich habe versucht:

# 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() 

Ich habe keine Ahnung, wie Diagramm wie Abbildung rechts zu schaffen?

Die Hilfe wird sehr geschätzt.

Weiterführende Links:
https://plot.ly/python/polar-chart/

+2

Ich bin ziemlich sicher, dass die „Spinnendiagramm“ Sie zitieren nicht die gleichen Grundstück wie das ist, das Sie duplizieren möchten. Die Spider-Plot in der Literatur ist eine Methode zur Darstellung multidimensionaler Daten. –

Antwort

2

Sie können versuchen, diese eine ähnliche Handlung zu bekommen (mit den Parametern spielen zu modifizieren, die einem gewünschten ähneln). Was Sie brauchen, ist contour plot, da Sie eine bivariate Funktion y=f(x,phi) haben.
Autor:

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() 

enter image description here

+0

Es gibt: RuntimeWarning: ungültiger Wert in Multiplikation gefunden –

2

Diese Frage genommen Sparke und Gallagher
Buch: Galaxien im Universum 2. Auflage
Kurs: Astrophysik

Borrowing Ideen aus Sandipan, I habe es so gemacht:

#!/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() 

Das resultierende Bild ist:

enter image description here

enter image description here

enter image description here

enter image description here

UPDATE

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() 

enter image description here

+0

Schön, upvoted, aber sieht es genau wie die ursprüngliche Figur? –

+1

@SandipanDey Danke für die Idee, ich versuche immer noch, es genau zu machen! –

Verwandte Themen