- Plot the heatmap on an external figure
- Use imagesc() instead to plot the equivalent of a heatmap on your GUI axes.
Heatmap seems to delete axes component
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jason
am 14 Jan. 2020
Kommentiert: Adam Danz
am 15 Jan. 2020
Hello, I am creating a heatmap and displaying it on an axes component (GUIDE), B is my matrix data.
ax=axes(handles.axes2)
h1 = heatmap(ax,B);
h1.Colormap = cool;
h1.CellLabelFormat = '%.1f';
This works.
However, if in another function (checkbox callback) I try to get the handle to the axes component, it reports its an invalid handle (I do include handles as my argument to the function)
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% Hint: get(hObject,'Value') returns toggle state of checkbox1
val= get(hObject,'Value')
if val==1
object_handles=findobj(gcf)
axes(handles.axes2)
%I want to just change the colormap of the heatmap and thought I could then do
hh=gca
hh.Colormap = cool;
end
Could the heatmap be deleting my axes component?
Error using axes
Invalid axes handle
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 14 Jan. 2020
Bearbeitet: Adam Danz
am 14 Jan. 2020
In reference to this part of your quesiton:
ax=axes(handles.axes2)
h1 = heatmap(ax,B);
h1.Colormap = cool;
h1.CellLabelFormat = '%.1f';
"This works."
That code couldn't possibly work for the following reasons.
First, this line below should throw an error since the axes(cax) syntax does not support an output when the input is an axes handle. The only exception would be if handles.axes2 is actually a figure handle which would make that variable name a really bad one.
ax=axes(handles.axes2)
Error using axes
Too many output arguments.
Second, this line below should also throw an error since an axes cannot be specified as the first input (a figure can, though). h = heatmap(parent,___)
h1 = heatmap(ax,B);
Error using heatmap (line 76)
HeatmapChart cannot be a child of Axes.
You cannot plot a heatmap on a GUI axes. Your options are
2 Kommentare
Adam Danz
am 15 Jan. 2020
In the line below, I'm assuming handles.axes2 is a figure handle (not an axes handle). If the input were an axes handle, this line would result in an error.
ax=axes(handles.axes2)
Assuming handles.axes2 is a figure handle, ax would be an axes handle.
Then, this line below would throw an error since the parent of a heatmap chart cannot be an axes.
h1 = heatmap(ax,B);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!