- 博客(79)
- 资源 (2)
- 收藏
- 关注
翻译 绘制带彩色标记的散点图
import matplotlib.pyplot as pltimport numpy as npx = np.random.rand(1000)# 不相关数据y1 = np.random.rand(len(x))# 强正相关数据y2 = 1.2 + np.exp(x)ax1 = plt.subplot(121)# alpha:透明度# marker:设置点状标记plt.
2017-10-23 21:39:42 1307
翻译 绘制带填充区域的图表
import matplotlib.pyplot as pltimport numpy as npx = np.arange(0.0, 2, 0.01)y1 = np.sin(2 * np.pi * x)y2 = 1.2 * np.sin(4 * np.pi * x)fig = plt.figure()ax = plt.gca()ax.plot(x, y1, x, y2, c
2017-10-23 21:35:53 548
翻译 绘制饼图
import matplotlib.pyplot as pltplt.figure(1, figsize=(6, 6))ax = plt.axes([0.1, 0.1, 0.8, 0.8])# 饼图按逆时针顺序画出labels = 'Spring', 'Summer', 'Autumn', 'Winter'# 饼图每部分定义为x/sum(x),或者x if sum(x) <= 1
2017-10-23 21:33:29 524
翻译 绘制误差条形图
import matplotlib.pyplot as pltimport numpy as npx = np.arange(2, 10, 1)y = np.log(x)xe = 0.1 * np.abs(np.random.rand(len(y)))# 创建误差条形图'''left:x轴的位置序列height:y轴的数值序列,即柱形图的高度xerr/yerr:用于在柱状
2017-10-23 21:32:30 4511
翻译 绘制直方图
from matplotlib import pyplot as pltimport numpy as npmu = 100sigma = 15x = np.random.normal(mu, sigma, 10000)ax = plt.gca()# 调用plt.hist()创建直方图'''bins:可以是一个bin数量的整数值,也可以是表示bin的一个序列。默认值为10r
2017-10-23 21:30:29 405
翻译 移动轴线到图中央
from matplotlib import pyplot as pltimport numpy as npx = np.linspace(-np.pi, np.pi, 500, endpoint=True)y = np.sin(x)plt.plot(x, y)# 移动轴线到图中央ax = plt.gca()# 隐藏上和右两条脊柱,将其设置为无色ax.spines['rig
2017-10-23 21:29:32 308
翻译 添加图例和注解
from matplotlib import pyplot as pltimport numpy as npx1 = np.random.normal(30, 3, 100)x2 = np.random.normal(20, 2, 100)x3 = np.random.normal(10, 3, 100)# 如果不想在图例中显示标签,可将标签设置为_nolegend_。plt.pl
2017-10-23 21:27:54 3230
翻译 设置刻度、刻度标签和网格
from matplotlib import pyplot as pltimport matplotlib as mplimport numpy as npimport datetime'''# 返回当前显示图形的轴axisax = plt.gca()# 设置紧凑视图# nbins设置坐标轴一共平均分为几份,也可以显式的指定坐标轴,通过面向对象的方式或pyplot的方式# a
2017-10-23 21:26:00 1217
翻译 设置图表的线型、属性和格式化字符串
from matplotlib import pyplot as pltx = [1, 3, 5, 7, 9]y = [2, 4, 6, 8, 10]'''# 改变线的属性# 第一种方式,向方法传入关键字参数来指定线型plt.plot(x, y, linewidth=15)''''''# 第二种方式,对plot()方法调用返回的线条实例(matplotlib.lines.L
2017-10-23 21:24:53 383
翻译 设置坐标轴长度和范围
from matplotlib import pyplot as plt# axis()返回坐标轴的默认值(0.0, 1.0, 0.0, 1.0),(xmin, xmax, ymin, ymax)plt.axis()# 设置x轴和y轴的值ax_values = [-1, 1, -10, 10]plt.axis(ax_values)# plt.autoscale(),该方法会计算坐
2017-10-23 21:22:55 8663
翻译 简单的正弦图和余弦图
from matplotlib import pyplot as pltimport numpy as np'''numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None) retstep=True, return (samples, st
2017-10-23 21:20:47 4591
翻译 定义图表类型——柱状图、线形图和堆积柱状图
from matplotlib import pyplot as pltx = [1, 2, 3, 4]y = [5, 4, 3, 2]dataset = [113, 115, 119, 121, 124, 124, 125, 126, 126, 126, 127, 127, 128, 129, 130, 130, 131,
2017-10-23 21:15:08 2467
翻译 数字信号产生之解析信号的产生
fft.h #pragma once#include #define pi 3.14159265359class fft{private: double * x, * y; double c, c1, e, s, s1, t, tr, ti; int n, sign, i, j, k, l, m, n1, n2;public: fft() {}
2013-09-03 11:11:17 1202
翻译 数字信号产生之含有高斯白噪声的正弦组合信号的产生
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; int * seed; int s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generate()
2013-09-03 11:09:37 3215
翻译 数字信号产生之ARMA模型数据的产生
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; int * seed; int s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generat
2013-09-03 11:05:31 1475
翻译 数字信号产生之泊松分布的随机数
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; int * seed; int s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generat
2013-09-03 11:03:39 1790 1
翻译 数字信号产生之二项分布的随机数
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; int * seed; int s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generat
2013-09-03 11:02:08 1089
翻译 数字信号产生之贝努里高斯分布的随机数
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; int * seed; int s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generat
2013-09-03 11:01:20 832
翻译 数字信号产生之韦伯分布的随机数
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; int * seed; int s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void gene
2013-09-03 10:59:15 2464 1
翻译 数字信号产生之贝努里分布的随机数
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; int * seed; int s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generat
2013-09-03 10:57:41 724
翻译 数字信号产生之艾尔朗分布的随机数
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; int * seed; int s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generat
2013-09-03 10:55:44 847
翻译 数字信号产生之柯西分布的随机数
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; int * seed; int s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generat
2013-09-03 10:53:35 2502
翻译 数字信号产生之对数正态分布的随机数
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; int * seed; int s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generat
2013-09-03 10:50:30 1017
翻译 数字信号产生之瑞利分布的随机数
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; int * seed; int s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generat
2013-09-03 10:48:13 3329
翻译 数字信号产生之指数分布的随机数
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; int * seed; int s, M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generate(); do
2013-09-03 10:43:32 984
翻译 数字信号产生之正态分布的随机数
uniform.h #pragma onceclass uniform{private: double a, b, generate_num; long * seed; long s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generate
2013-09-03 10:39:37 847
翻译 数字信号产生之均匀分布的随机数
uniform.h#pragma onceclass uniform{private: double a, b, generate_num; long * seed; long s; int M, N, i, j;public: uniform() { M = 1048576; N = 2045; } void generate(
2013-09-03 10:37:41 677
转载 求解常微分方程边值问题之试射法
//用试射法求解边值问题#include #include #include #include using namespace std;class s_ode{private: int i, j, l, n; double a, b, c, d, h, x, x1, xi, xf; double *b1, *b2, *b3, *g, *y, *y1;
2013-08-13 11:12:44 1361
转载 求解常微分方程初值问题之Milne预报-校正法
//实现Milne预报-校正法#include #include #include using namespace std;class milne{private: int i, n; double f, h, x, x_last, y, y1, y2, y3, yc, yp; double f0, f1, f2;public: double fun
2013-08-13 11:11:32 1678
转载 求解常微分方程初值问题之多步Euler预报-校正法
//实现多步Euler法#include #include #include using namespace std;class multi_euler{private: int i, n; double f, h, x, x_last, yc, yc_old, yp;public: double func(double z, double t) {
2013-08-13 11:10:42 1246
转载 求解常微分方程初值问题之多变量Runge_Kutta_Gill法
//用RKG法求解常微分方程组#include #include #include #include using namespace std;class s_ode{private: int i, j, l, n; double a, b, c, d, h, x, x1, xi, xf; double *b1, *b2, *b3, *g, *y, *y1
2013-08-13 11:09:29 1810
转载 求解常微分方程初值问题之Runge_Kutta_Fehlberg法
//用Runge_Kutta_Fehlberg法求解微分方程#include #include #include #include using namespace std;class rkf{private: int flag; double eps, error, f, h, hnew, x, xf, y, yold; double k1, k2, k
2013-08-13 11:07:47 2034
转载 求解常微分方程初值问题之Runge_Kutta法
//用RKG法求解微分方程#include #include #include using namespace std;class rkg{private: int i, n; double a, b, c, d, f, h, k1, k2, k3, k4, x, xf, y;public: double func(double z, double t)
2013-08-13 11:06:55 1020
转载 求解常微分方程初值问题之改进Euler法:预报-校正公式
//实现Euler预报_校正法#include #include #include using namespace std;class euler{private: int i, n; double f, h, x, x_last, yc, yp;public: double func(double z, double t) { f = (1
2013-08-13 11:05:28 3788
转载 Richardson外推法计算给定点处的一阶和二阶导数
//计算给定点处的一阶和二阶导数#include #include using namespace std;class deriv{private: int k; double d1, d1_1, d1_2, d2, d2_1, d2_2, d1_new, d2_new; double f_x, f_xhm, f_x2hm, f_xhp, f_x2hp, h,
2013-08-13 11:03:17 3946
转载 数值积分之Simpson 3/8法则
//实现Simpson 3/8法则#include #include using namespace std;class simpson2{private: int n, k; double a, b, f, integral, interval, one_third_interval; double sum_term1, sum_term2, sum_term
2013-08-08 18:40:58 2756
转载 数值积分之Simpson 1/3法则
//实现Simpson 1/3法则#include #include using namespace std;class simpson{private: int n, k; double a, b, f, half_interval, integral, interval, sum_even_terms; double sum_odd_terms, x;p
2013-08-08 18:40:23 2439
转载 数值积分之Romberg求积法
//Romberg求积法#include #include #include using namespace std;class romberg{private: int i, j, imax, jmax; double f, h, a, b, term1, term2, **I;public: double func(double x) {
2013-08-08 18:39:42 1574
转载 数值积分之Gauss求积法五点公式
//Gauss求积法五点公式#include #include using namespace std;class quadrature{private: int i; double a, b, f, integral, sum; double w[5], x[5];public: double func(double r) { f = 8.1
2013-08-08 18:38:59 9281
转载 数值积分之Newton_Cotes闭合积分公式
//Newton_Cotes闭合积分公式#include #include using namespace std;class trapezoidal{private: int n, k; double a, b, f, h, integral, sum;public: double func(double v) { f = 24.6 / (v -
2013-08-08 18:37:35 1846
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人