Mathematica数据处理(5)--Plot
来源:互联网 发布:wireshark过滤端口 编辑:程序博客网 时间:2024/05/18 02:39
今天这一篇文章,我们来讲一下画图
我们会分为2D和3D的来分别讲述
首先让我们看一下在Mathematica中画图的函数有多少
fun = Names["*Plot"];Grid[Partition[fun, 3, 1],Background -> {None, {{LightBlue, LightRed}}}, Frame -> All]
来看看,这是结果
很明显,我这里要讲完这么多是不可能的,所以我们就挑几个讲一下
首先讲2D的
最重要的当然是Plot,相信大家都已经会用了,我就放一个简单的例子
Plot[2*E^(2*x), {x, 0, 4}, PlotLabel -> Style[Plot, 24],ImageSize -> Large]
得到下面的图
下面讲一下 对数图,对数线性图,双对数图
我们以对数图为例讲一下
对数图其实就是将y轴的坐标做了Log的运算。
例如上图,在对数图下面就是一条直线,这么做是为了更好发现数据之间的关系的
下面举个例子
GraphicsRow[{ LogPlot[2*E^(2*x), {x, 0, 4}, PlotLabel -> Style[LogPlot, 24], ImageSize -> Medium], (*以y为对数坐标画图,相当于y轴坐标做了一个Log的变换,注意此时y轴为对数刻度,只是坐标变了,数字并没有变化*) LogLinearPlot[2*E^(2*x), {x, 1, 4}, PlotLabel -> Style[LogLinearPlot, 24], ImageSize -> Medium], (*x是对数*) LogLogPlot[2*E^(2*x), {x, 1, 4}, PlotLabel -> Style[LogLogPlot, 24], ImageSize -> Medium] (*x,y都是对数*) }]
得到如下的图
当然,还有极坐标画图
PolarPlot[t, {t, 0, 20}]
得到如下的图
下面讲一下3D的作图
Plot3D是可以直接画出3D的图像的
f[x_, y_] := Sin[x^2 + y^2]/(x^2 + y^2 + 1);Plot3D[f[x, y], {x, -4, 4}, {y, -4, 4},PlotLabel -> Style[Plot3D, 24], PlotTheme -> "Classic"]
如下图
有的时候,对于三维的图,虽说很直观,但是一些数据并不容易观察出,此时我们就需要借助
密度图 和 绘制等高线
GraphicsRow[{ DensityPlot[f[x, y], {x, -4, 4}, {y, -4, 4}, PlotLabel -> Style[DensityPlot, 24], ImageSize -> Medium, ColorFunction -> "CMYKColors"], ContourPlot[f[x, y], {x, -4, 4}, {y, -4, 4}, PlotLabel -> Style[ContourPlot, 24], ImageSize -> Medium, ColorFunction -> "CMYKColors"] }](*一般来说,颜色越浅,对应的函数值就越大*)(*等高线图就是把密度图分成若干份*)
得到如下的图
我们还可以把图画的更好一些,加一些注释
Column[{ DensityPlot[f[x, y], {x, -4, 4}, {y, -4, 4}, PlotLabel -> Style[DensityPlot, 24], ImageSize -> Medium, ColorFunction -> "CMYKColors"], BarLegend[{"CMYKColors", range}, LegendLayout -> "Row", LegendMarkerSize -> 400] }, Center]
得到下面的图
可以看到黑色的地方函数值是最大的,和我们在3D图上看到的是一样的
最后我们看三种 球 的画法
GraphicsRow[{ ParametricPlot3D[{Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]}, {v, 0, 2 Pi}, {u, 0, 2 Pi}, PlotLabel -> Style["三位参数图", 24], ImageSize -> Medium, ColorFunction -> ColorData["TemperatureMap"]], SphericalPlot3D[1, {\[Theta], 0, 2 Pi}, {\[Phi], 0, 2 Pi}, PlotLabel -> Style["三维球面图", 24], ImageSize -> Medium, ColorFunction -> ColorData["TemperatureMap"]], RevolutionPlot3D[{Cos[t], Sin[t]}, {t, -Pi/2, Pi/2}, PlotLabel -> Style["三维旋转图", 24], ImageSize -> Large, ColorFunction -> ColorData["TemperatureMap"]] }, ImageSize -> Full]
得到下面的图
上面就是关于Mathematica画图的一些知识
2016/8/11
以上,所有
0 0
- Mathematica数据处理(5)--Plot
- Mathematica数据处理(2)
- Mathematica数据处理(3)
- Mathematica数据处理(4)
- Mathematica数据处理(11)--标签
- Mathematica数据处理(12)--图例
- Mathematica数据处理(1)--安斯库母四重奏
- Mathematica数据处理(6)--散点图(上)
- Mathematica数据处理(7)--散点图(下)
- Mathematica数据处理(8)--美化(上)
- Mathematica数据处理(9)--美化(中)
- Mathematica数据处理(10)--美化(下)
- Mathematica数据处理(13)--显示坐标
- 让3D Plot类型的图片旋转起来...(Mathematica)
- Mathematica
- Mathematica
- plot
- Mathematica 讲座
- NSDate
- Java7并发编程--4.1、创建线程执行器
- win7 64位 Caffe+Cuda6.5+Opencv3.10+Boost1.56配置
- POJ 1088 滑雪(简单DFS+dp)
- c/c++注释转换函数
- Mathematica数据处理(5)--Plot
- 初学C语言:斐波那契数列(求前n项和)
- iOS——navigationBar色差问题
- 【Leetcode】143. Reorder List - 链表重排序
- 回型矩阵
- 提升架构能力
- IM模块-文本添加表情
- iOS开发 - 键盘的收起
- 最长公共子串