关于ContourPlot的小问题
mathematica吧
全部回复
仅看楼主
level 6
frokaikan 楼主
如图所示,在RegionPlot画出来的范围中画出8^x+2^y的等高线。
原代码:Remove["Global`*"];
Show[RegionPlot[
x + 2 y - 1 >= 0 && 2 x + y - 2 <= 0 && x - y + 2 >= 0, {x, -1,
1}, {y, 0, 2}, ColorFunction -> "Rainbow"],
ContourPlot[8^x + 2^y, {x, -1, 1}, {y, 0, 2}],
AspectRatio -> Automatic, AxesOrigin -> {0, 0},Frame->False,Axes->True]
但是画出来跟没有RegionPlot一样。。彩色地方根本没有。能否修改?应如何修改?。。多谢大神。二楼贴图。
2014年10月10日 16点10分 1
level 6
frokaikan 楼主
第一个是原代码,第二个是单独RegionPlot。
多谢!
2014年10月10日 16点10分 2
level 11
ContourPlot[8^x + 2^y, {x, -1, 1}, {y, 0, 2}, ColorFunction -> Hue,
PlotRange -> {0, 12}, Contours -> 500, ContourStyle -> None]
试试这个,
其中,Contours是等高线的条数,一般设置为10到100之间就可以了。
ContourStyle是等高线的样式,这里设置的不显示,不喜欢就删掉此项。
2014年10月11日 01点10分 3
level 11
此外,函数Show是用来叠加显示多张图片的,后面的覆盖前面的。
这样就能显示出来了。
Remove["Global`*"];
Show[ContourPlot[8^x + 2^y, {x, -1, 1}, {y, 0, 2},
ColorFunction -> "Rainbow"],
RegionPlot[
x + 2 y - 1 >= 0 && 2 x + y - 2 <= 0 && x - y + 2 >= 0, {x, -1,
1}, {y, 0, 2}, ColorFunction -> "Rainbow"],
AspectRatio -> Automatic, AxesOrigin -> {0, 0}, Frame -> False,
Axes -> True]
2014年10月11日 01点10分 4
level 11
或者加上参数
PlotStyle -> Opacity[0.5]
设置透明度
Show[ContourPlot[8^x + 2^y, {x, -1, 1}, {y, 0, 2},
ColorFunction -> "Rainbow"],
RegionPlot[
x + 2 y - 1 >= 0 && 2 x + y - 2 <= 0 && x - y + 2 >= 0, {x, -1,
1}, {y, 0, 2}, ColorFunction -> "Rainbow",
PlotStyle -> Opacity[0.5]], AspectRatio -> Automatic,
AxesOrigin -> {0, 0}, Frame -> False, Axes -> True]
2014年10月11日 01点10分 5
多谢,忘记Opacity。[哈哈]
2014年10月11日 08点10分
1