LoginSignup
1
1

More than 5 years have passed since last update.

DensityPlotで作った複数の図に透明度を持たせて重ねたいとき

Posted at

全体に透明度を持たせるなら
BaseStyle->Opacity[0.5]
などでOK。
値によって透明度を変化させたいときはColorFunctionのオプションで以下のようにする。例えば値が最小のとき透明で最大のとき不透明なグレースケールは
ColorFunction ->( {Opacity[#],Blend[{White,Black},#]}& )で作れる。
なお()は評価順序の都合のため必要。

density=DensityPlot[Tanh[x],{x,-3,3},{y,-3,3},
  ColorFunction->({Blend[{White,Black},#],Opacity[#}}&),
  FrameTicks->None,
  PlotPoints->100,
  ImageSize->300
];
wave=DensityPlot[Sin[(2 Pi x)/0.5]*Exp[-x*x-y*y],{x,-3,3},{y,-3,3},
  ColorFunction->(Blend[{Blue,White,Red},#]&),
  FrameTicks->None,
  PlotPoints->100,
  ImageSize->300
];
Overlay[
  {density,wave}
];

overlaywithalpha.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1