0

I'm working on creating a graph in Matplotlib. I'm having issues where the graph's borders are cutting into my labels as seen in this screenshot:

enter image description here

I'm trying to remove the boundary line on the top and right side of the graph. I know that the code looks like this in plotly, but I'm unsure of matplotlib's equivalent.

fig.update_xaxes(showline=True, linewidth=1, linecolor='#FBFBFB', mirror=False)
fig.update_yaxes(showgrid=True, gridwidth=1, gridcolor="#FBFBFB",showline=True, linewidth=2, linecolor='#FBFBFB', mirror=False)

Here is my entire code for context:

import matplotlib.pyplot as plt
from connect_to_db import get_df2

df = get_df2()

ax = df.plot(x='A', y='B', fontsize=10, color='#6C90B6', linewidth=3.0, legend=False,
             xlabel='', ylabel='B', figsize=(10, 5)).grid(axis='y')

for i in range(len(df)):
    x = df['A'][i]
    y = df['B'][i]
    plt.plot(x, y, 'bo', color='#6C90B6')
    plt.text(x, y + 3, y, fontsize=12, horizontalalignment='center')

plt.show()
Nora
  • 55
  • 6
  • If you change the upper limit for the _y_ axis there is no overlap… – gboffi Oct 12 '20 at 19:56
  • @gboffi Thanks, in this particular scenario, I need the live removed because I'm replicating a graph that does not have it. – Nora Oct 12 '20 at 20:23
  • Does this answer your question? [How can I remove the top and right axis in matplotlib?](https://stackoverflow.com/questions/925024/how-can-i-remove-the-top-and-right-axis-in-matplotlib) – gboffi Oct 12 '20 at 20:39
  • I have tried that option before, and I get an error "Can't read NoneType object." – Nora Oct 13 '20 at 12:36
  • My advice: close this question and post another one, where you describe what you have done to remove the spines and what went wrong. Ciao. – gboffi Oct 14 '20 at 09:53

0 Answers0