How to color grids underneath a curve and also gradient the grids depending on how much is within curve?
3 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have a grid that exists underneath an arc. I want to color each grid underneath the arc any color. If the entire grid is under the curve, I want the color to be max intensity. If the grid is on the edge of the arc, I want the grid to be varying levels of intensity in color shade. For example, if it is 50% above the curve and 50% below the curve, I will have the greyscale at half the color of the grid that is fully underneath the curve. What is a good way to do this?
here is my simple code that has the grid and the arc curve :)
xCenter = 10;
yCenter = 10;
radius = 10;
theta = linspace(180, 270, 50);
x = radius * cosd(theta) + xCenter;
y = radius * sind(theta) + yCenter;
plot(x, y);
axis ([ 0 24 0 24]);
grid on;
set(gca,'DataAspectRatio',[1 1 1])
xticks(0:1:10)
yticks([0:1:10])
0 件のコメント
回答 (1 件)
Matt J
2021 年 5 月 11 日
One way,
xCenter = 10;
yCenter = 10;
radius = 10;
theta = linspace(180, 270, 50);
x = radius * cosd(theta) + xCenter;
y = radius * sind(theta) + yCenter;
pgon=polyshape([x,flip(x)],[y,0*y]);
plot(pgon,'FaceAlpha',area(pgon)/100);
axis ([ 0 24 0 24]);
grid on;
set(gca,'DataAspectRatio',[1 1 1])
xticks(0:1:10)
yticks([0:1:10])
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Colormaps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!