Let me note that there is not any typographical rule that states that the below method is any way correct. It can merely be used if one wishes to control the dash's placement.
One way to do this is to add a command which adds a non-hyphenated dash.
This can be done with
\nobreakdash. However, this will not allow any hyphenation until the next word (i.e. no hyphenation in the axis word). Thus one should add a space which breaks the words
A solution would be
% Requires amsmath package
This will show this:
Hello, this is the a $x$-axis
Hello, this is the a $x$\dirdash-axis
Hello, this is the a $x$-longword
Hello, this is the a $x$\dirdash-longword
And yield the following output