There is a schedule:

import numpy as np import matplotlib.pyplot as plt def deg_to_rad(deg): return (deg * np.pi) / 180 X = np.arange(360) Y = np.sin(deg_to_rad(X)) plt.plot(X,Y) ax = plt.gca() ax.spines['left'].set_position('center') ax.spines['bottom'].set_position('center') ax.spines['top'].set_visible(False) ax.spines['right'].set_visible(False) plt.show() 

enter image description here

It is necessary to rename the labels along the X axis, namely, the coordinate 90 renamed to п/2 , the coordinate 180 to п , the coordinate 270 to 3п/2 and the coordinate 360 to 2п , all other marks should be removed.

Since the labels with coordinates 90 , 180 , 270 , 360 initially absent altogether, they must also be added in some way.

How to add and rename them?

    1 answer 1

    UPDATE: use degrees instead of radians for the x-axis and rewrite the labels (Latex) manually

     X = np.arange(-180, 181) Y = np.sin(np.deg2rad(X)) plt.plot(X,Y) ax = plt.gca() ax.spines['left'].set_position('center') ax.spines['bottom'].set_position('center') ax.spines['top'].set_visible(False) ax.spines['right'].set_visible(False) points = np.array([-np.pi, -np.pi/2, 0, np.pi/2, np.pi]) labels = [r'-$\pi$', r'-$\frac{\pi}{2}$', '$0$', r'$\frac{\pi}{2}$', r'$\pi$'] plt.xticks(np.rad2deg(points), labels) 

    Result:

    enter image description here

    • Thank you, what you need) - Igor igoryanych
    • For radians understandable, but I can not understand how to rename the scale X for degrees? - Igor Igoryanych
    • @ IgorIgoryanych, now I will try ... - MaxU
    • it would be super) - Igor Igoryanych
    • Exactly what you need! - Igor Igoryanych