Skip to content Skip to sidebar Skip to footer

Matplotlib Secondary_y Cause Plot To Shift Right

I was hoping someone could help me with an issue. I am trying to plot a line graph over a bar graph. Below is a link to the line graph and the code: fig, ax = plt.subplots(figsize=

Solution 1:

There is no "shift". The bars are positionned such that the first bar starts at position 0, the second at 1 etc. The line graph starts at position 1; this is the position where the second bar is shown. Only due to the labeling, this appears to be wrong. But mind that the label could also read "banana" in which case one would not wonder too much about the resulting plot.

In order to overcome this, you may shift your line plot manually by 1 unit.

Post a Comment for "Matplotlib Secondary_y Cause Plot To Shift Right"