How to create two different graphs on top of each other, On a GUI, one visible and one not and then switch between them?

3 ビュー (過去 30 日間)
Alon Rozen
Alon Rozen 2016 年 11 月 27 日
回答済み: Alon Rozen 2016 年 11 月 28 日
Hi All,
I created a GUI, using GUIDE, and in it I placed 2 different axes exactly on top of each other. My Idea is to create a different graph in each of them but to make only a selected one of them visible. To achieve this I added a group of two radio buttons to select the axes (with its graphs) that should be visible. For example - to switch between the now visible 'My_Axes_1' and the non visible 'My_Axes_2' I used:
My_Axes_1.Visible = 'Off';
My_Axes_2.Visible = 'On';
This seems to work. What is not working is that after creating the first graph on the first axes the other graph on the second axes is visible!. I tried many My_Axes_2.Visible = 'Off' during the creation of the graph but never succeeded to get a clear picture.
How can I plot the second graph and have this graph and its axes non visible until I use the right radio button?
Thanks,
Alon
  2 件のコメント
Stephen23
Stephen23 2016 年 11 月 27 日
編集済み: Stephen23 2016 年 11 月 27 日
What MATLAB version are you using?
If you want an example of code that does exactly what you want, have a look at my FEX submission brewermap, where the function brewermap_view includes a button that selects between 2D and 3D views of the colormaps. It works exactly as you describe (on pre-2014 MATLAB only).
Alon Rozen
Alon Rozen 2016 年 11 月 27 日
Thanks Stephen,
I am using the last Matlab release - 2016b. So I guess there will be problems.

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

回答 (1 件)

Alon Rozen
Alon Rozen 2016 年 11 月 28 日
Hi all,
After some research and a lot of trial and error the picture became clear and a solution emerged.
The problem is that 'axes' is separated from the graphs, legends and other 'creatures' which are added later. In order to fully switch between one 'axes' and all what is drawn on it and another set you have to change the visibility to 'off' for each component. While this works fine its a bit cumbersome.
A much simpler solution is to have each axes be part of a different 'panel' and to have both panels have the same dimensions, position and color (just on top of each other). Then all you have to do is to change the first 'panel' visibility to 'off' and turn the others visibility to 'on' (or vise versa). This way you smoothly switch between them.
Works like charm in Matlab 20165b.

カテゴリ

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