Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

comment changer l'affichage de l'axe des ordonnées d'un graphique

1 réponse
Avatar
Fab
Bonjour,

le programme suivant m'affiche une =C3=A9chelle dans le coin en haut =C3=A0=
gauche du graphique.
Je n'en veux pas, je pr=C3=A9f=C3=A8re voir les nombres enti=C3=A8rement =
=C3=A9crit sur l'axe des ordonn=C3=A9es.

Comment faire ?

import matplotlib.pyplot as repere
repere.plot(0,0.0000001,"ro")
repere.plot(1,0.0000002,"ro")
repere.show()

Merci,
Fabrice.

1 réponse

Avatar
Nicolas
Bonjour,
Le 04/12/2018 à 18:42, Fab a écrit :
Bonjour,
le programme suivant m'affiche une échelle dans le coin en haut à gauche du graphique.
Je n'en veux pas, je préfère voir les nombres entièrement écrit sur l'axe des ordonnées.
Comment faire ?
import matplotlib.pyplot as repere
repere.plot(0,0.0000001,"ro")
repere.plot(1,0.0000002,"ro")
repere.show()
Merci,
Fabrice.

import matplotlib.pyplot as repere
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
majorLocator = MultipleLocator(0.00000005) # Tick avec information
minorLocator = MultipleLocator(0.00000001) # Tick sans information
majorFormatter = FormatStrFormatter('%1.8f')
fig = repere.subplot(1,1,1)
fig.plot(0,0.0000001,"ro", drawstyle='default')
fig.plot(1,0.0000002,"ro", drawstyle='default')
fig.set_yscale('linear')
y_axis = fig.get_yaxis()
#y_axis.get_major_formatter().set_useOffset(False)
y_axis.set_major_locator(majorLocator)
y_axis.set_minor_locator(minorLocator)
y_axis.set_major_formatter(majorFormatter)
repere.ylabel('Amplitude')
repere.show()
Plus d'infos ici : # https://matplotlib.org/api/ticker_api.html
Nicolas