Adjusting size of plot in Matlab so that graph does not get cut off by edge of plot window

前端 未结 3 2095
北海茫月
北海茫月 2021-01-07 03:26

I\'ve created a plot in Matlab, but unfortunately the side of the plot is cut off by the plotting window. Here is the code that I\'ve used to create the plot:



        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-07 04:17

    The following document (How to produce figures with Matlab that have the right dimensions when printed) provides some example code that can be used to resize the plot in the proper fashion.

    The following code was used:

    point = num(:, 1);
    depth = num(:, 2);
    
    hfig = plot(point, depth, '-s', 'Color', 'k', 'MarkerFaceColor', 'k', 'MarkerEdgeColor', 'k', 'MarkerSize', 10);
    set(gca, 'LineWidth', axis_size);
    set(gca,'FontSize', ticksize, 'FontName', fontname);
    set(gcf,'PaperUnits','centimeters')
    xSize = 30; ySize = 5;
    xLeft = (21-xSize)/2; yTop = (30-ySize)/2;
    set(gcf,'PaperPosition',[xLeft yTop xSize ySize])
    set(gcf,'Position',[300 600 xSize*50 ySize*50])
    
    xlabel('Point Number');
    ylabel('Depth (cm)');  
    

    Here is a picture of the result. This looks similar to the one that I posted in my question above. I don't know if this is dependent on monitor size and/or screen resolution.

    Expected result

提交回复
热议问题