Я пытаюсь выяснить, как добавить оси к моей полярной проекции.Предполагается, что вновь добавленные оси будут обтекать исходные полярные оси как кольцо.
Для этой цели я попытался использовать append_axes
от делителя, созданного с помощью make_axes_locatable
в проекции polar
matplotlib ax
.
Тем не менее, нет никакой опции для "внешней" или чего-либо, что напоминало бы полярные проекции с аргументами append_axes
.Вместо кольца вокруг осей я получаю новые оси чуть ниже исходной (см. Рисунок).
Есть ли какая-либо альтернатива, которая позволила бы создать оси в форме кольца вокруг существующих полярных осей?
Обратите внимание, я не хочу добавлять их на один и тот же топор, потому что весы могут быть разными.
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
plt.style.use("seaborn-white")
def synthesize(polar=False):
fig = plt.figure()
ax = fig.add_subplot(111, polar=polar)
t = np.linspace(0,2*np.pi)
r_sin = np.sin(t)
r_cos = np.cos(t)
for r in [r_sin, r_cos]:
ax.scatter(t, r, c=r, s=t*100, edgecolor="white", cmap=plt.cm.magma_r)
ax.scatter(t, -r, c=r, s=t*100, edgecolor="white", cmap=plt.cm.magma_r)
ax.set_title("polar={}".format(polar),fontsize=15)
ax.set_xticklabels([])
return fig, ax, t
# Rectilinear
fig, ax, t = synthesize(polar=False)
# Here are the plot dimensions in response to the answer below
xlim = ax.get_xlim()
ylim = ax.get_ylim()
rlim = (ax.get_rmin(), ax.get_rmax())
print(xlim, ylim, rlim)
(0.0, 6.283185307179586) (0.0, 2.2437621373846617) (0.0, 2.2437621373846617)
# Encircling axis
divider = make_axes_locatable(ax)
ax_below = divider.append_axes("bottom", size="32.8%", pad=0.1)
ax_below.scatter(t, np.tan(t), c="black", edgecolor="white")
# Polar
fig, ax, t = synthesize(polar=True)
divider = make_axes_locatable(ax)
ax_below = divider.append_axes("bottom", size="32.8%", pad=0.1)
ax_below.scatter(t, np.tan(t), c="black", edgecolor="white")
