Matlab脚本在输出.eps中将黑色渲染为紫色



我有一个MATLAB脚本来渲染数据(在这种情况下是一个由许多矩形组成的时间线),在MATLAB图形查看器中一切都很好。然而,由于某种原因,当我使用print将文件输出为.eps时,一些黑色(图中的文本和框)会变为紫色。

    static = importdata( 'output.out');
    static(:,3) = ( static(:,3) - static(:,2) ) * tpms;
    start = min( static(:,2) );
    static(:,2) = ( static(:,2) - start ) * tpms;
    ms_max = max(static(:,2)) - min(static(:,2))
    ms_max = ms_max + 0.1 * ms_max;
    %ms_max = max(static(:,2)) - min(static(:,2));
    static_corner = static( static(:,1)==0 , : );
    static_row = static( static(:,1)==1 , : );
    static_column = static( static(:,1)==2 , : );
    static_split = static( static(:,1) == 3, :);
    %static_rest = static( static(:,1)==3 , : );
    static_unload = static( static(:,1)==-101 , : );
    static_load = static( static(:,1)==-100 , : );
    static_ghost = static(static(:,1)==-102,:);
    % Init the plot
    clf;
    subplot('position',[ 0.05 , 0.1 , 0.9 , 0.8 ]);
    hold on;
    % Plot the selfs in RED
    for k=1:size(static_corner,1)
        rectangle( 'Position' , [ static_corner(k,2) , static_corner(k,4)+0.5 , static_corner(k,3) , 1 ] , ...
    'EdgeColor' , [ 0.8 0 0 ] , 'LineWidth' , 1 , 'FaceColor' , [ 1 0 0 ] );
    end
    arrays = 0.0;
    for k=1:size(static_corner,1)
        arrays = arrays + static_corner(k,3);
    end
    arrays/size(static_corner,1)

    % Plot the pairs in GREEN
    for k=1:size(static_row,1)
        rectangle( 'Position' , [ static_row(k,2) , static_row(k,4)+0.5 , static_row(k,3) , 1 ] , ...
    'EdgeColor' , [ 0 0.8 0 ] , 'LineWidth' , 1 , 'FaceColor' , [ 0 1 0 ] );
    end
    arrays = 0.0;
    for k=1:size(static_row,1)
        arrays = arrays + static_row(k,3);
    end
    arrays/size(static_row,1)
    % Plot the pc in BLUE
    for k=1:size(static_column,1)
        rectangle( 'Position' , [ static_column(k,2) , static_column(k,4)+0.5 , static_column(k,3) , 1 ] , ...
    'EdgeColor' , [ 0 0 0.8 ] , 'LineWidth' , 1 , 'FaceColor' , [ 0 0 1 ] );
    end
    arrays = 0.0;
    for k=1:size(static_column,1)
        arrays = arrays + static_column(k,3);
    end
    arrays/size(static_column,1)

    % Plot the pc in BLUE
    for k=1:size(static_split, 1)
        rectangle( 'Position' , [ static_split(k,2) , static_split(k,4)+0.5 , static_split(k,3) , 1 ] , ...
    'EdgeColor' , [ 0.6 0.6 0.0 ] , 'LineWidth' , 1 , 'FaceColor' , [ 1 1 0 ] );
    end
    arrays = 0.0;
    for k=1:size(static_split,1)
        arrays = arrays + static_split(k,3);
    end
    arrays/size(static_split,1)
    % Plot the unload
    for k=1:size(static_unload,1)
        rectangle( 'Position' , [ static_unload(k,2) , static_unload(k,4)+0.5 , static_unload(k,3) , 1 ] , ...
    'EdgeColor' , [ 0.0 0.6 0.6 ] , 'LineWidth' , 1 , 'FaceColor' , [ 0 1 1 ] );
    end
    % Plot the load
    for k=1:size(static_load,1)
        rectangle( 'Position' , [ static_load(k,2) ,         static_load(k,4)+0.5 , static_load(k,3) , 1 ] , ...
    'EdgeColor' , [ 0.6 0.0 0.6 ] , 'LineWidth' , 1 , 'FaceColor' , [ 1 0 1 ] );
    end
    %Plot the ghost in black
    for k=1:size(static_ghost,1)
        rectangle( 'Position' , [ static_ghost(k,2) , static_ghost(k,4)+0.5 , static_ghost(k,3) , 1 ] , ...
    'EdgeColor' , [ 0.0 0.0 0.0 ] , 'LineWidth' , 1 , 'FaceColor' , [ 0 0 0 ] );
    end
    hold off;
    xlabel('time (ms)');
    ylabel('block ID');
    set(gca,'YTick',0:8:128)
    title('Task plot for BH with simulated cudaMemcpy');
    axis([ 0 , ms_max , 0.5 , max(static(:,4))+1.5 ]);

    % Print this plot
    set( gcf , 'PaperSize' , 2.3*[ 30 4 ] );
    set( gcf , 'PaperPosition' , 2.3*[ 0.25 0.25 20 4 ] );
    %saveas(gcf, '/home/hudson/ug/d74ksy/PhD/BHTimers/tasks.eps', 'epsc');
    print(gcf, '/home/hudson/ug/d74ksy/PhD/BHTimers/tasks.eps', '-depsc' );

我尝试同时使用saveas和print,但无论哪种方式,我都会收到紫色文本。这是带有怪异色彩的情节输出。输出.eps我在linux上远程使用MATLAB R2014a。

任何人都知道为什么会发生这种情况——我需要设置文本颜色吗(尽管这不能解释为什么矩形会被绘制:

    rectangle( 'Position' , [ static_ghost(k,2) , static_ghost(k,4)+0.5 , static_ghost(k,3) , 1 ] , ...
'EdgeColor' , [ 0.0 0.0 0.0 ] , 'LineWidth' , 1 , 'FaceColor' , [ 0 0 0 ] );

也是紫色

答案/解决方法:将xlabel/ylaabel/set/title/aaxis命令移动到保持之前;线,并将绘制黑框的部分移动为第一个绘制的框,解决了问题。

最新更新