why is the color bar disrupting my GUI output??

조회 수: 2 (최근 30일)
Giorgos
Giorgos 2015년 8월 26일
댓글: Mohammed Al-Mosawi 2016년 6월 11일
I am making a GUI with matlab. I have 4 axes each displaying a figure that is generated from a script, that has input from the user through a drop-down menu. though as the user clicks for the first time the GUI seems to work perfectly, while if the user chooses a second selection axes3 disappears.
After looking into the code I figured out the piece of code that is causing the trouble:
axes(handles.axes3);
y1 = 1:10;
[AX A B]=plotyy(Data_last_values(:,9),Data_last_values(:,6),Data_last_values(:,9),Data_last_values(:,8), @(x, y) scatter(x, y, [], Data_last_values(:,5)));%-> volumetric mass flow is used in the color bar
colormap(jet(20));
h=colorbar;
ylabel(AX(1), 'T_{in} [C]');
ylabel(AX(2), 'DT [C]');
xlabel('Q_{out} [W]')
ylabel(h, 'Volumetric Flow [Lt/min]')
title('figure 1 - Heat Exchanger HEX')
grid minor
I noticed that if I comment out the colorbar everything works perfectly, or replace the plotyy with scatter. The plot that I would like to make is a double yy scatter plot with a colorbar.
Any help would be super aprciated !! :)

답변 (1개)

Walter Roberson
Walter Roberson 2015년 8월 26일
Remember that plotyy() creates a new axes for the second y. That axes might or might not be the current axes after the plotyy() call. colorbar() by default works on the current axes.
You should be calling colorbar with the axes you want it to be associated with.
Note: before R2014b, colorbar creates an axes itself, and that axes could become the current axes too. From R2014b onwards, colorbar creates a colorbar object rather than a new axes.
  댓글 수: 1
Mohammed Al-Mosawi
Mohammed Al-Mosawi 2016년 6월 11일
I am having the same problem, and I dont understand your answer

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by