bar() to a specific axes in GUI

7 views (last 30 days)
Obadah M.
Obadah M. on 18 Nov 2018
Commented: Rik on 22 Nov 2018
Hello,
I have 3 axes in my gui, and I'm trying to plot a bar graph on one of them. I have tried several solutions; however, I have had no luck.
I may have not applied the solution properly.
The answers above indicate that I should use: axes(handles.axes1); Though I'm not really sure which function I should place it in.
Any input is really appreciated

Accepted Answer

Rik
Rik on 18 Nov 2018
You should always use explicit handles. You could indeed use the code you describe (which you would then need to put just before the call to bar).
But there is an easier solution: use explicit handles in your call to bar. If you read the doc, you see you have two options: specifying the axes as the first argument, or using the Name-Value pair to specify the parent axes.
  24 Comments
Obadah M.
Obadah M. on 22 Nov 2018
Edited: Obadah M. on 22 Nov 2018
Okay thank you Rik!
You have posted an improved version of the function I posted, however; I would still like to know what is causing this "bug". The whole area from 0 to -40 is red, is it another bar?
x = [0 0.5 1];
y = [0 cels 0];
bar (x, y, 'r', 'BaseValue', -40, 'LineWidth', 0.7)
set(gca, 'xtick', [], 'ytick', [])
axis([0 1 -40 120]);
Rik
Rik on 22 Nov 2018
With the base value you indicate what should be the lower value of your bar plot. Then you choose to plot 3 bars, so you get 3 red stacks. I have already showed you what I would use as code, so I'm not going to look into big parts of your code.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Objects in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!