Fix bug with changing x-axis variable