How to adjust position of axis name and legend

After I converted a ggplot to plotly, the y-axis name is too close to tick marks and the legend is overlapping with the plot. I hope to adjust the horizontal position of the axis name and the legend. Anyone knows if it is possible? Thanks!

I adjusted positioning of legend using the following code in javascript.

legend: {
      "x": "0",
       "margin.r": "120"
    }

For a full discussion of the problem (still unresolved), see this Github issue https://github.com/ropensci/plotly/issues/510.