diff --git a/plot_transmission_timeline.py b/plot_transmission_timeline.py index 0303a59..3e2d3d7 100755 --- a/plot_transmission_timeline.py +++ b/plot_transmission_timeline.py @@ -187,8 +187,15 @@ if __name__ == "__main__": plt.figure(figsize=[6.4 * scaley, 4.8 * scalex]) plt.title("{} with {}".format(transmission_direction, cc_algo)) - host = host_subplot(111, axes_class=axisartist.Axes) - plt.subplots_adjust() + fig, ax = plt.subplots() + fig.subplots_adjust(right=0.75) + + twin1 = ax.twinx() + twin2 = ax.twinx() + # Offset the right spine of twin2. The ticks and label have already been + # placed on the right by twinx above. + twin2.spines.right.set_position(("axes", 1.2)) + # create list fo color indices transmission_df["index"] = transmission_df.index @@ -208,35 +215,33 @@ if __name__ == "__main__": cmap = matplotlib.cm.get_cmap("Set3") for c in transmission_df["cell_color"].unique(): bounds = transmission_df[["index", "cell_color"]].groupby("cell_color").agg(["min", "max"]).loc[c] - host.axvspan(bounds.min(), bounds.max(), alpha=0.3, color=cmap.colors[c]) + ax.axvspan(bounds.min(), bounds.max(), alpha=0.3, color=cmap.colors[c]) + p1, = ax.plot(transmission_df["goodput_rolling"], "-", color="blue", label="goodput") + p2, = twin1.plot(transmission_df["downlink_cqi"], "--", color="green", label="CQI") + p3, = twin2.plot(transmission_df["ack_rtt"], "-.", color="red", label="ACK RTT") - host.plot(transmission_df["goodput_rolling"], "-", color="blue", label="goodput") - host.set_xlabel("datetime") - host.set_ylabel("goodput [Mbps]") - host.set_ylim([0, 500]) + ax.set_xlim(transmission_df["index"].min(), transmission_df["index"].max()) + ax.set_ylim(0, 500) + twin1.set_ylim(0, 15) + twin2.set_ylim(0, 1) - # additional y axes - par11 = host.twinx() - par12 = host.twinx() - #par13 = host.twinx() + ax.set_xlabel("Time") + ax.set_ylabel("Goodput") + twin1.set_ylabel("CQI") + twin2.set_ylabel("ACK RTT") - # axes offset - par12.axis["right"] = par12.new_fixed_axis(loc="right", offset=(60, 0)) - #par13.axis["right"] = par13.new_fixed_axis(loc="right", offset=(120, 0)) + ax.yaxis.label.set_color(p1.get_color()) + twin1.yaxis.label.set_color(p2.get_color()) + twin2.yaxis.label.set_color(p3.get_color()) - par11.axis["right"].toggle(all=True) - par12.axis["right"].toggle(all=True) - #par13.axis["right"].toggle(all=True) - - par11.plot(transmission_df["downlink_cqi"], "--", color="green", label="CQI") - par11.set_ylabel("CQI") - par11.set_ylim([0, 15]) - - par12.plot(transmission_df["ack_rtt"], "-.", color="red", label="ACK RTT") - par12.set_ylabel("ACK RTT [s]") - par12.set_ylim([0, 1]) + tkw = dict(size=4, width=1.5) + ax.tick_params(axis='y', colors=p1.get_color(), **tkw) + twin1.tick_params(axis='y', colors=p2.get_color(), **tkw) + twin2.tick_params(axis='y', colors=p3.get_color(), **tkw) + ax.tick_params(axis='x', **tkw) + ax.legend(handles=[p1, p2, p3]) if args.save: plt.savefig("{}timeline_plot.pdf".format(args.save))