как построить полярный и декартовый участки на одном графике, как показано на рисунке - PullRequest
1 голос
/ 13 октября 2019

Я хочу создать один график, который будет наполовину декартовым и наполовину полярным. например, половина гауссовой кривой в полярном формате и другая половина в декартовом формате. какой путь самый лучший?

plot which is half cartesian and half polar

Я пытался использовать общий доступ по оси Y, но не смог выбрать два разных формата для одного графика.

import matplotlib.pyplot as plt
import numpy as np

theta = np.linspace(0,(np.pi)/2)
r = np.sin(theta)

fig = plt.figure()
ax = fig.add_subplot(211, polar=True)
c = ax.scatter(theta, r, c=r, s=5, cmap='hsv', alpha=0.85)

ax.set_thetamin(0)
ax.set_thetamax(90)

ax1=fig.add_subplot(212) #, sharey='ax')
fig, (c, d) = plt.subplots(ncols=2,sharey=True)
d=ax1.scatter(theta,r)
plt.show() 

1 Ответ

2 голосов
/ 14 октября 2019
import matplotlib.pyplot as plt
import numpy as np

theta = np.linspace(0,(np.pi)/2)
r = np.sin(theta)

fig = plt.figure(figsize=(6.4, 3.25))
fig.subplots_adjust(wspace=0)
ax1 = fig.add_subplot(121)
ax1.grid()
ax2 = fig.add_subplot(122, polar=True)
ax2.set_thetamin(0)
ax2.set_thetamax(90)

ax1.set_ylim(0, 1.05)
ax2.set_ylim(0, 1.05)

sc1 = ax1.scatter(np.rad2deg(theta), r, c=r, s=5, cmap='hsv', alpha=0.85)
sc2 = ax2.scatter(theta,r, c=r, s=5, cmap='hsv', alpha=0.85)
plt.show() 

enter image description here

...