Ось остаточного графика не совпадает с осями графика - PullRequest
0 голосов
/ 25 марта 2020

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

# Plot with residuals


fig1 = plt.figure(figsize =(10,8))


ax = fig1.add_axes((0.2,0.4,.75,.6))

ax.plot(JD_inc, mag_inc, 'x', new_x_inc, new_y_inc)
ax.plot(JD_dec, mag_dec, 'x', new_x_dec, new_y_dec)

ax.errorbar(our_jul_day, our_mag, yerr = our_err, fmt = "x", color = "black", zorder = 10)

ax.plot(x_line,y_line, linestyle = "--", color = "black", zorder = 0)

ax.plot(JD_start, mag_start, 'x', zorder = 1, color = 'darkorchid')

ax.invert_yaxis()



positions = (2458725, 2458775, 2458825,2458875, 2458925)
labels = (2458725, 2458775, 2458825,2458875, 2458925)
plt.xticks(positions, labels)


ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')

# Axis labels
plt.xlabel('Julian Date', fontsize = 12)
plt.ylabel('Magnitude', fontsize = 12)



ax2 = fig1.add_axes((0.2,0.2,.75,0.2)) 
plt.xlabel("Julian Date", fontsize = 12)
plt.ylabel("Magnitude", fontsize = 12)    #\n is used to start a new line


ax2.plot(JD_inc,res_inc,"x")
ax2.plot(JD_dec,res_dec,"x", color = 'forestgreen')
ax2.plot(JD_start,res_start,'x', color = 'darkorchid')
ax2.plot(our_jul_day, res_our_data, 'x', color = 'black')

positions = (2458725, 2458775, 2458825,2458875, 2458925)
labels = (2458725, 2458775, 2458825,2458875, 2458925)
plt.xticks(positions, labels)




ax2.spines['right'].set_visible(False)
ax2.yaxis.set_ticks_position('left')
ax2.xaxis.set_ticks_position('bottom')

ax2.invert_yaxis()

plt.axhline(0, linewidth=1, linestyle="--", color="black")

Я полагаю, что проблема заключается в том, что я не понимаю, каковы аргументы fig.add_axes.

Вот как выглядит мой график:

1 Ответ

0 голосов
/ 25 марта 2020

Я, кажется, решил проблему, установив ограничения по осям X для обоих графиков, например:

ax.set_xlim([2458725, 2458940])
ax2.set_xlim([2458725, 2458940])
...