Figured it out a while ago thought I would leave the answer. Load the image into an axes and then it is possible to move the axes around and resize with the normal set(gca, 'position', [a b c d])
How to move matlab.graphics.primitive.Image (output of imagesc) within a figure?
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a function that is producing a spectrogram of data using imagesc, placing it in a figure, and saving it. For reasons relating to automation testing I need to move the image result of imagesc down very slightly within the figure. I've explored converting the output of imagesc to another format, however, that breaks other bits of code later on. All the normal get and set functions don't work as it is a matlab.graphics.primitive.Image.
fig = figure;
ax = axes(); % position gets set further down
set(ax, 'FontSize', FONT_SIZE_AXES(SpecInfo.resMode), 'Layer', 'Top')
imagesc(SpecData.time, (SpecData.freq/freqScale), SpecData.data);
axis xy
ylim(minmax(SpecData.freq/freqScale))
colormap(cm);
set(ax, 'Clim', colourScale);
This goes on to add all the titles, axis information, and such and save it as a png using ghostscript. All the normal get and set functions don't work as it is a matlab.graphics.primitive.Image. Perhaps the easist way is to convert to a rbg image array move it and then convert back to a matlab.graphics.primitive.Image? Or change the rest of the code to handle a rgb image array?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!