calculate ratio inside plot_pos def