horizontal bar plot (from a negative to a positive value in the same line)

4 ビュー (過去 30 日間)
Ioannis Vourvachakis
Ioannis Vourvachakis 2022 年 4 月 4 日
コメント済み: Star Strider 2022 年 4 月 4 日
Hello,
I am trying to make a horizontal bar plot that will construct a bar for example from -5 to 5.
like the plot in the following picture.
Can anyone help me?
Thank you.

回答 (1 件)

Star Strider
Star Strider 2022 年 4 月 4 日
Try this —
figure
patch([-5 5 5 -5], [0.25 0.25 0.75 0.75], 'b', 'FaceAlpha',0.5, 'EdgeColor','none')
axis([-5 5 0 1])
xtix = [-5 -3 -1 1 3 5];
set(gca, 'XTick',xtix, 'XGrid','on', 'XColor','none', 'YColor','none')
text(xtix, zeros(size(xtix)), string(xtix), 'Horiz','center', 'Vert','top')
xline(0, 'Color',[1 1 1]*0.75, 'LineWidth',1.5)
.
  2 件のコメント
Ioannis Vourvachakis
Ioannis Vourvachakis 2022 年 4 月 4 日
Thank you Star, but I don't think that this is exactly what I am looking for. Imagine that at the end I want to make a plot like this
What can I do?
Star Strider
Star Strider 2022 年 4 月 4 日
My pleasure.
I don't think that this is exactly what I am looking for
That is specifically what you asked for!
See the documentation for the barh function.
The SimBiology Toolbox or the Bioinformatics Toolbox may have those sorts of plots as built-in functions. I could not find anything similar to that when I looked, however I did not look closely.
.

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

カテゴリ

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