MATLAB Answers

Heatmap creates new windows on each call; only one computer

3 views (last 30 days)
M S on 12 Aug 2012
I have a really strange problem. I have matlab installed at both work and at home. At work tonight, I generated a bunch of data, and wrote a very short script to view the data as a heatmap. Each datafile I read is a joint probability distribution and viewing each as a heatmap is helpful. This script just lets me flash through heatmaps, each one replacing the next in the same window upon key press. You can ignore sread5: think of it as a dlmread for my data. A is a matrix.
clear all
for i=0:576
However, upon running this exact code at home, the script opens up a new HeatMap object everytime it's called. To be specific, on the first iteration I get a window "Figure 1" which is empty, and a second window "HeatMap 1" which contains my heatmap. This already differs from running it at work, where only a single window opens on the first iteration. Then, on the second iteration, a new figure window opens called "HeatMap 2". Etc. So on iteration 5, I have 6 windows open instead of 1, like when I run this script at work.
To be clear, I have all my includes and scripts saved in a dropbox folder, so when I open a script at home, it's literally the identical file with identical dependencies, etc. This makes me think that the weird windowing problem has something to do with a matlab setting. But I haven't been able to find any such setting that might control this behavior. Thoughts? Thanks in advance for your time.

Answers (3)

Walter Roberson
Walter Roberson on 12 Aug 2012
Edited: Walter Roberson on 12 Aug 2012
Check the default settings
Also, are the MATLAB versions the same, and the same 32 vs 64 bits?
  1 Comment
M S on 12 Aug 2012
Good question, I'll have to check tomorrow. Running R2011a 64bit at home. I'm pretty sure it's either R2011a or b, 64-bit at work.
I don't know how to interpret the command you gave me there. None of the settings listed appear to govern how many copies of the figure open. Also, when I use plot normally, calling plot a second time [correctly] plots the new plot in the same window as the first, overwriting it.

Sign in to comment.

M S on 12 Aug 2012
EDIT: Partially solved... now this gets real weird, perhaps someone can explain.
The heatmap function I'm calling is something I downloaded from the file exchange. Thinking there'd be some instructions regarding the behavior of heatmaps, I looked at their heatmap_examples.m file. I tried running it. Amazingly, the heatmap function called in their example file works perfectly fine (only opens 1 window despite multiple calls). But when I go to run my original script, I still get the multiple window behavior. I then tried loading 1 piece of data to memory, navigating to the heatmap_examples.m file, running it in debug mode, then plotting heatmap of my data on command line, and it appropriately replaces the example heatmap with my data's heatmap, in the same figure.
So then I tried just copy/pasting my heatmap script above along with some data to a new folder. Works perfectly. This is "solved" I guess, but what the heck is going on??

per isakson
per isakson on 12 Aug 2012
Edited: per isakson on 13 Aug 2012
Is this the FEX-contribution that you use?
Customizable Heat Maps by Ameya Deoras
Visualize data as a heatmap with many customizable options.
There are at least two version:
21 Dec 2011
Major update. New features include:
* Text labels correctly update when figure is zoomed, panned or resized
* X tick labels can be rotated
* Show all or a subset of tick labels for large matrices
The signature of this function, heatmap, is
[hImage, hText, hXText] = heatmap(mat, xlab, ylab, textmat, varargin)
With your code I just get an error
Index exceeds matrix dimensions.
Error in heatmap>setAxesLabels (line 280)
Set breakpoint at 280
280 set(p.hAxes,'YTick',ytick,'YTickLabel',ylab(ytick));
K>> ylab
ylab =
K>> ytick
ytick =
2 4 6 8 10 12 14
Question remains: what heatmap are you running?
The handle graphic objects, figure and axes, have a property named, Nextplot (see the code of the function, hold). Could it be that the default values of Nextplot differs between your computers?
get( 0,'defaultFigureNextPlot' )
get( 0,'defaultAxesNextPlot' )
I get (R2012a,64bit)
ans =
ans =
@Walter, The commamd
doesn't report these values here.

Community Treasure Hunt

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

Start Hunting!

Translated by