How to prevent xticklabels from being cutoff

58 Views Asked by At

is there a way to modify a matplotlib plot to ensure that the x-axis tick labels are fully visible?

I wrote below python code to plot GPA of some students on a diagram but x-axis tick aren't seen.

import matplotlib.pyplot as plt
import numpy as np

a = np.random.rand(10)*4
xlabel = []
for i in range(10):
    xlabel.append(f"GPA of student {i}")
plt.plot(xlabel,a)
plt.title("Plot a test diagram")
plt.xticks(xlabel,rotation=90)
plt.show()

enter image description here

1

There are 1 best solutions below

0
On

There is an icon in your plot window that you can use it to edit your plot.

  1. click on configure subplots in your plot window
  2. Modify the values in the boxes to shift your plot in any direction.