0

When displaying a plot via Jupyter Notebook in VSC (newest version, 1.106.3) the graph is getting rendered in the right upper corner, and the labels in the lower left corner. I already restarted VSC and created a new venv. Anybody has an idea how to fix this? I tried multiple approaches in Python 3.12 and 3.13.

Currently in Python 3.12.0 with Matplotlib 3.10.7

Output image 1:

1

counts = df['flower_class'].value_counts()

plt.figure(figsize=(12,6))
plt.bar(counts.index, counts.values)
plt.xlabel('Class')
plt.ylabel('Aantal voorbeelden')
plt.title('Verdeling van classes')
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
plt.show()

Output image 2:

2

counts = df['flower_class'].value_counts()

plt.figure(figsize=(12,6))
counts.plot(kind='bar')
plt.xlabel('Class')
plt.ylabel('Aantal voorbeelden')
plt.title('Verdeling van classes')
plt.show()
New contributor
Milan N is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
3
  • 1
    Your code works perfectly for me. Do you have the same issue without Jupyter Notebook outside VSCode ? Commented Nov 27 at 19:33
  • 4
    You should include a complete reproducible example, maybe the labels just have a lot of whitespace at the end? Commented Nov 27 at 19:57
  • Thanks that was the case! The labels have a lot whitespace indeed. Commented 2 days ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.