Page 1 of 1

Wie man die wissenschaftliche Notationsform in Matplotlib verändert

Posted: 10 Feb 2025, 12:25
by Anonymous
Dies ist mein Code. < /p>

Code: Select all

time = sig[:, 0]                                                    # data first column: time
displacement = sig[:, 1]                                            # data second column: displacement

font = {'family': 'Times New Roman', 'weight': 'bold', 'size': 16}
fig, ax = plt.subplots(figsize = (9, 8))                            # set figure size (width,height)

ax.plot(time, displacement, linewidth = 2)

ax.set_xlim(0, 3e-3)                                                # set x-axis limit
ax.set_ylim(-4e-6, 1e-6)                                            # set y-axis limit

ax.set_xticklabels([0, 0.5, 1, 1.5, 2, 2.5, 3])
ax.tick_params(labelsize = 16)                                      # tick_params can only change label size
labels = ax.get_xticklabels() + ax.get_yticklabels()
for label in labels:                                                # thus use for loop(?) change font name and weight
label.set_fontname('Times New Roman')
label.set_fontweight('bold')

ax.set_xlabel('Time (msec.)', font)
ax.set_ylabel('Displacement (m)', font)

plt.show()
< /code>
Und dies ist das Ergebnis des Code. Wie kann ich das Notationsformular von 1E-6 
auf 10^-6 ändern und auch die Schriftart fett machen.