简体   繁体   中英

want to set y-axis label values in line chart

折线图

want to display the yaxis label in the range 0.2 to 0.8 in the range of 0.2.

example: 0.2, 0.4, 0.6, 0.8

code:

plt.axis=([0,0.45,0.2,0.8])
plt.plot([0.2,0.25,0.3,0.35,0.4,0.45],[0.5,0.6,0.60,0.5,0.5,0.6])

This can be setted with yticks and np.arrange as follows:

import matplotlib.pyplot as plt
import numpy as np

plt.plot([0.2,0.25,0.3,0.35,0.4,0.45],[0.5,0.6,0.60,0.5,0.5,0.6])
plt.yticks(np.arange(0.2, 0.8, step=0.2))
plt.show()

阴谋 Here is the documentation for yticks

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM