Place grid on top of patches

127 ビュー (過去 30 日間)
Niccolò Moro
Niccolò Moro 2020 年 5 月 30 日
コメント済み: Star Strider 2022 年 7 月 5 日
Hi everybody,
I want to place a grid (only y-axis) on top of my graph which is covered by patches. The patches are 15% transparent, therefor the grid can already bee seen slightly. However, it would be way better to see the whole grid. Does anyone have an input how to achieve this?
At the moment i call the grid like this:
set(gca, 'XGrid', 'on', 'YGrid', 'off');
This is the current state of the graph:
Thank you for your input.

採用された回答

Star Strider
Star Strider 2020 年 5 月 30 日
編集済み: Star Strider 2020 年 5 月 30 日
The gridlines can be put on top of the figure, and you can also vary the transparency of the grid lines.
Example —
x = 1:10;
y = rand(2, 10);
figure
subplot(2,1,1)
patch([x fliplr(x)], [y(1,:) fliplr(y(2,:))+1], 'r', 'FaceAlpha', 0.3)
Ax = gca;
Ax.YGrid = 'on';
Ax.GridAlpha = 0.5;
subplot(2,1,2)
patch([x fliplr(x)], [y(1,:) fliplr(y(2,:))+1], 'r', 'FaceAlpha', 0.3)
Ax = gca;
Ax.YGrid = 'on';
Ax.Layer = 'top';
Ax.GridAlpha = 0.5;
See the documentation section on Axis Properties and specifically: Grids for more options.
EDIT —
Added plot image
.
  5 件のコメント
Ernst Uzhanskii
Ernst Uzhanskii 2022 年 7 月 4 日
Many thanks!
Star Strider
Star Strider 2022 年 7 月 5 日
My pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by