利用python的matplotlib库进行简单的绘图

利用python的matplotlib库进行简单的绘图,第1张

利用python的matplotlib库进行简单的绘图
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 15 21:19:53 2021

@author: Machi
"""

import matplotlib.pyplot as plt
import numpy as np

%config InlineBackend.figure_format = 'retina'
x = np.linspace(0, 2, 100)
# Note that even in the OO-style, we use `.pyplot.figure` to create the␣
#↪figure.
fig, ax = plt.subplots() # Create a figure and an axes.
ax.plot(x, x, label='linear') # Plot some data on the axes.
ax.plot(x, x**2, label='quadratic') # Plot more data on the axes...
ax.plot(x, x**3, label='cubic') # ... and some more.
ax.set_xlabel('x label') # Add an x-label to the axes.
ax.set_ylabel('y label') # Add a y-label to the axes.
ax.set_title("Simple Plot") # Add a title to the axes.
ax.legend() # Add a legend.

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5495675.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存