Center legend affecting graph, not legend

Using the following code:


It looks like it’s centering the graph, not the legend. Am I doing something wrong ?


what if you try:


Thanks Etienne.
Weirdly enough, I used x=0.15. 0.5 was too far to the right. I will keep the “x=” in mind.


how can you have the legend just simply on top of the chart in the middle ?

because orientation=‘v’ places it on the right side
and orientation=‘h’ places it on the bottom which then usually overlaps the ticks of the x-axis.
the “safe position” would be as a one liner on top of the chart area but below the title.