简体   繁体   中英

How to add title and customize x and y axis of a figure

ax.set(title="simple plot",
      xlabel="x-axis",
      ylabel="y-axis")

fig.savefig("image/sample-plot.png")

simple plot

I checked matplotlib version to see if it's an old one.

Here is an example

y_vals =[1,2,3,4,5]
x_label = [1,2,3,4,5]
plt.ylabel("%")
plt.xlabel("months")
plt.xticks(x_label,["jan","feb","mars","apr","etc"])
plt.plot(x_label,y_vals)
plt.savefig("sample-plot.png")
plt.show()

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