设为首页 加入收藏

TOP

Python matplotlib 绘图保存图片简单示例
2019-03-24 00:08:04 】 浏览:190
Tags:Python matplotlib 绘图 保存 图片 简单 示例

from cycler import cycler
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt


# Define a list of markevery cases and color cases to plot
cases = [None,
        8,
        (30, 8),
        [16, 24, 30],
        [0, -1],
        slice(100, 200, 3),
        0.1,
        0.3,
        1.5,
        (0.0, 0.1),
        (0.45, 0.1)]


colors = ['#1f77b4',
          '#ff7f0e',
          '#2ca02c',
          '#d62728',
          '#9467bd',
          '#8c564b',
          '#e377c2',
          '#7f7f7f',
          '#bcbd22',
          '#17becf',
          '#1a55FF']


# Configure rcParams axes.prop_cycle to simultaneously cycle cases and colors.
mpl.rcParams['axes.prop_cycle'] = cycler(markevery=cases, color=colors)


# Create data points and offsets
x = np.linspace(0, 2 * np.pi)
offsets = np.linspace(0, 2 * np.pi, 11, endpoint=False)
yy = np.transpose([np.sin(x + phi) for phi in offsets])


# Set the plot curve with markers and a title
fig = plt.figure()
ax = fig.add_axes([0.1, 0.1, 0.6, 0.75])


for i in range(len(cases)):
    ax.plot(yy[:, i], marker='o', label=str(cases[i]))
    ax.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0.)


plt.show()



】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Python matplotlib基础绘图函数示.. 下一篇Java常用API及Math类

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目