wolfram-mathematica - 轮廓图 : Styling contour lines

标签 wolfram-mathematica

我可以绘制对应于隐式方程的曲线:

ContourPlot[x^2 + (2 y)^2 == 1, {x, -1, 1}, {y, -1, 1}]

但我找不到根据点的位置为等高线着色的方法。更准确地说,我想用两种颜色给曲线上色,这取决于 x² + y² < k 与否。

我查看了 ColorFunction,但这仅用于为等高线之间的区域着色。 而且我无法让 ContourStyle 接受位置相关的表达式。

最佳答案

您可以使用 RegionFunction 将图一分为二:

Show[{
  ContourPlot[x^2 + (2 y)^2 == 1, {x, -1, 1}, {y, -1, 1}, 
  RegionFunction -> Function[{x, y, z}, x^2 + y^2 < .5], 
  ContourStyle -> Red], 
  ContourPlot[x^2 + (2 y)^2 == 1, {x, -1, 1}, {y, -1, 1}, 
  RegionFunction -> Function[{x, y, z}, x^2 + y^2 >= .5], 
  ContourStyle -> Green]
}]

Mathematica graphics

关于wolfram-mathematica - 轮廓图 : Styling contour lines,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8963095/

相关文章:

wolfram-mathematica - 如何控制图像和图形的大小?

list - 数学: adding a list of lists elementwise

wolfram-mathematica - 如何在mathematica中提取有单位的数字?

math - mathematica 输出中的 "$"符号

wolfram-mathematica - 在 Mathematica 中重复函数 n 次

wolfram-mathematica - 如何创建具有正确格式表达式的笔记本

wolfram-mathematica - 制作表格的速度差异

wolfram-mathematica - 如何在 Mathematica 中为矩阵乘法重载 Times 和 Plus

wolfram-mathematica - IntegerPartition 的变体?

python - 拟合曲线: which model to describe distribution in weighted knowledge graphs