Matlab locks up when saving figure with color map using scatter()

1 回表示 (過去 30 日間)
Daniel
Daniel 2015 年 1 月 2 日
コメント済み: Maryam Abdolahpour 2023 年 7 月 28 日
I have a Matlab program that generates 3 figures: 2 use the plot() function and the 3rd uses the scatter() function which color maps the points based on a 3rd dimension. The plot() types all display fine and the first 2 I save as jpeg files using print() with no issues; however, when I try to save the 3rd colormapped plot to jpeg using print(), the process is extremely slow (an hour vs. seconds for the normal plots) and I have to use windows task manager to close it if I don't want to wait. If I go to the File menu in the figure itself and try to save as jpeg it does the same thing. I attached the .fig file to this post (below). Using saveas() causes the same issue. The second to last line, "print('-djpeg', file_jpg, '-r300')", is where it bogs down. Is there an alternative method to print() or saveas() that might be faster?
I'm using Matlab R2014a with Windows 7.
figure
subplot(2,1,1);
plot(sec_from_start, WVSS2F_VMR, sec_from_start, WVSS2R_VMR,'-g', sec_from_start, VMR_C_U,'cx',sec_from_start, VMR_CR2,'-k', sec_from_start, wmr_GE_s,'-y');
hold on; %holds plot and axis properties
plot( sec_from_start, PALT_RVS,'.r')
title(file,'Interpreter','none')
TAS_thresh=100; %start plot when TAS exceeds a threshold (m/s)
for i = 1:length(PALT_RVS)
if TAS(i) > TAS_thresh
time_plot_start = sec_from_start(i); %start time for plots
break
end
end
axis([time_plot_start, max(sec_from_start), 0, 14000])
l=legend(firsty,secondy,thirdy,forthy,fifthy,sixy); set(l,'Interpreter','none')
xlabel('time (sec from start)')
ylabel('PPMv, Palt (m)')
grid
WVSS_ERR = WVSS2F_VMR - wmr_GE_s; %WVSS2 minus GE chilled mirror
subplot(2,1,2)
[AX, H1, H2] = plotyy(sec_from_start, WVSS2F_VMR, sec_from_start, WVSS_ERR);
%set(H2, 'Marker','.');
set(H2, 'Color','r');
set(get(AX(1),'Ylabel'),'String','PPMv'); %set left Y-axis
set(get(AX(2),'Ylabel'),'String','PPMv error'); %set right Y-axis
set(AX(1),'xlim',[time_plot_start, max(sec_from_start)]);
set(AX(2),'xlim',[time_plot_start, max(sec_from_start)]);
set(AX(2),'ylim',[-2000 2000]);
set(AX(2),'YTick',[-2000 -1000 0 1000 2000]);
xlabel('time (sec from start)')
%title(file,'Interpreter','none')
l=legend(firsty, 'error (WVSS2F-GE chilled mir.)'); set(l,'Interpreter','none')
grid
file_jpg = [path_file, '_out.jpg'];
print('-djpeg', file_jpg, '-r300'); %save figure to file with resolution rXXX
figure
[H] = plot(wmr_GE_s, WVSS2F_VMR);
set(H, 'Color','b'); set(H, 'marker', '.'); set(H, 'line', 'none')
ylabel('WVSS2 (PPMv)'); %set left Y-axis
xlabel('GE chilled mirror (PPMv)')
axis([0, 40000, 0, 40000])
title(file,'Interpreter','none')
l=legend('WVSS2F vs. GE chilled mir.'); set(l,'Interpreter','none')
set(gca,'xTick',0:5000:40000)
set(gca,'yTick',0:5000:40000)
grid
file_jpg = [path_file, '_scatter_out.jpg'];
print('-djpeg', file_jpg, '-r300'); %save figure to file with resolution rXXX
hold on;
figure
%%plot with colormap
colormap(jet); %defines bype of color map for points in scatter plot
cmin = 0; cmax = 200; V=[cmin, cmax];
scatter1 = scatter(wmr_GE_s,WVSS2F_VMR,10,TAS_RVSM);
caxis(V); %set color map range
hcb = colorbar('YTick', [cmin 0 cmax],'YTickLabel', {num2str(cmin),' Palt=0 m', num2str(cmax)}); %add colorbar scale to plot
ylabel('WVSS2 (PPMv)'); %set left Y-axis
xlabel('GE chilled mirror (PPMv)')
axis([0, 40000, 0, 40000])
set(gca,'xTick',0:5000:40000)
set(gca,'yTick',0:5000:40000)
title('test','Interpreter','none')
grid
file_jpg = [path_file, '_scatter_color_out.jpg'];
print('-djpeg', file_jpg, '-r300'); %save figure to file with resolution rXXX
%saveas(gcf, file_jpg); %save figure to file with resolution rXXX
  1 件のコメント
Maryam Abdolahpour
Maryam Abdolahpour 2023 年 7 月 28 日
I have exactly the same issue in my Matlab 2017 and Matlab 2022

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeRed についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by